- move some definitions around
[m6w6/ext-http] / http.c
diff --git a/http.c b/http.c
index cbc38eb7208972603761e9ecd454f8dd07a02f0d..fc7f15a3964361f984200bc6403ebf905642351e 100644 (file)
--- a/http.c
+++ b/http.c
 #include "php_http_request_method_api.h"
 #ifdef HTTP_HAVE_CURL
 #      include "php_http_request_api.h"
+#      include "php_http_request_pool_api.h"
 #      include "php_http_request_datashare_api.h"
+#      ifdef HTTP_HAVE_PERSISTENT_HANDLES
+#              include "php_http_persistent_handle_api.h"
+#      endif
 #endif
 #ifdef HTTP_HAVE_ZLIB
 #      include "php_http_encoding_api.h"
@@ -68,7 +72,6 @@ ZEND_GET_MODULE(http)
 
 /* {{{ http_functions[] */
 zend_function_entry http_functions[] = {
-       PHP_FE(http_test, NULL)
        PHP_FE(http_date, NULL)
        PHP_FE(http_build_url, http_arg_pass_ref_4)
        PHP_FE(http_build_str, NULL)
@@ -102,6 +105,10 @@ zend_function_entry http_functions[] = {
        PHP_FE(http_get_request_body_stream, NULL)
        PHP_FE(http_match_request_header, NULL)
 #ifdef HTTP_HAVE_CURL
+#      ifdef HTTP_HAVE_PERSISTENT_HANDLES
+       PHP_FE(http_persistent_handles_count, NULL)
+       PHP_FE(http_persistent_handles_clean, NULL)
+#      endif
        PHP_FE(http_get, http_arg_pass_ref_3)
        PHP_FE(http_head, http_arg_pass_ref_3)
        PHP_FE(http_post_data, http_arg_pass_ref_4)
@@ -187,7 +194,7 @@ static void http_globals_init_once(zend_http_globals *G)
 static inline void _http_globals_init(zend_http_globals *G TSRMLS_DC)
 {
 #ifdef HTTP_HAVE_SAPI_RTIME
-       G->request.time = Z_LVAL_P(http_get_server_var("REQUEST_TIME"));
+       G->request.time = sapi_get_request_time(TSRMLS_C);
 #else
        G->request.time = time(NULL);
 #endif
@@ -206,6 +213,10 @@ static inline void _http_globals_free(zend_http_globals *G TSRMLS_DC)
        }
        STR_SET(G->send.content_type, NULL);
        STR_SET(G->send.unquoted_etag, NULL);
+       if (G->server_var) {
+               zval_ptr_dtor(&G->server_var);
+               G->server_var = NULL;
+       }
 }
 /* }}} */
 
@@ -277,6 +288,10 @@ PHP_MINIT_FUNCTION(http)
                        (SUCCESS != PHP_MINIT_CALL(http_send))          ||
                        (SUCCESS != PHP_MINIT_CALL(http_url))           ||
 #ifdef HTTP_HAVE_CURL
+#      ifdef HTTP_HAVE_PERSISTENT_HANDLES
+                       (SUCCESS != PHP_MINIT_CALL(http_persistent_handle)) ||
+                       (SUCCESS != PHP_MINIT_CALL(http_request_pool)) ||
+#      endif
                        (SUCCESS != PHP_MINIT_CALL(http_request))       ||
 #      ifdef ZEND_ENGINE_2
                        (SUCCESS != PHP_MINIT_CALL(http_request_datashare)) ||
@@ -324,7 +339,11 @@ PHP_MSHUTDOWN_FUNCTION(http)
 #      ifdef ZEND_ENGINE_2
                        (SUCCESS != PHP_MSHUTDOWN_CALL(http_request_datashare)) ||
 #      endif
-                       (SUCCESS != PHP_MSHUTDOWN_CALL(http_request))) {
+                       (SUCCESS != PHP_MSHUTDOWN_CALL(http_request))
+#      ifdef HTTP_HAVE_PERSISTENT_HANDLES
+                       || (SUCCESS != PHP_MSHUTDOWN_CALL(http_persistent_handle))
+#      endif
+       ) {
                return FAILURE;
        }
 #endif