X-Git-Url: https://git.m6w6.name/?a=blobdiff_plain;f=http.c;h=4e1f0b356331aa3f319ed3046a3329093176cad2;hb=4f232fcd18f54f824fcefcbc76a8413a7db94799;hp=1261de8a3855470840f66c392b32339ba0561e81;hpb=adeb28c27b5ee0ce27d477a42815f8fdee8bf9fe;p=m6w6%2Fext-http diff --git a/http.c b/http.c index 1261de8..4e1f0b3 100644 --- a/http.c +++ b/http.c @@ -308,6 +308,10 @@ zend_function_entry httpi_request_class_methods[] = { PHP_ME(HTTPi_Request, setOptions, NULL, ZEND_ACC_PUBLIC) PHP_ME(HTTPi_Request, getOptions, NULL, ZEND_ACC_PUBLIC) + PHP_ME(HTTPi_Request, unsetOptions, NULL, ZEND_ACC_PUBLIC) + + PHP_ME(HTTPi_Request, addHeader, NULL, ZEND_ACC_PUBLIC) + PHP_ME(HTTPi_Request, addCookie, NULL, ZEND_ACC_PUBLIC) PHP_ME(HTTPi_Request, setMethod, NULL, ZEND_ACC_PUBLIC) PHP_ME(HTTPi_Request, getMethod, NULL, ZEND_ACC_PUBLIC) @@ -430,17 +434,39 @@ PHP_INI_BEGIN() PHP_INI_END() /* }}} */ +/* {{{ HTTP_CURL_USE_ZEND_MM */ +#if defined(HTTP_HAVE_CURL) && defined(HTTP_CURL_USE_ZEND_MM) +static void http_curl_free(void *p) { efree(p); } +static char *http_curl_strdup(const char *p) { return estrdup(p); } +static void *http_curl_malloc(size_t s) { return emalloc(s); } +static void *http_curl_realloc(void *p, size_t s) { return erealloc(p, s); } +static void *http_curl_calloc(size_t n, size_t s) { return ecalloc(n, s); } +#endif /* HTTP_HAVE_CURL && HTTP_CURL_USE_ZEND_MM */ +/* }}} */ + /* {{{ PHP_MINIT_FUNCTION */ PHP_MINIT_FUNCTION(http) { ZEND_INIT_MODULE_GLOBALS(http, php_http_init_globals, NULL); REGISTER_INI_ENTRIES(); -#if defined(HTTP_HAVE_CURL) && (LIBCURL_VERSION_NUM >= 0x070a05) +#ifdef HTTP_HAVE_CURL +# ifdef HTTP_CURL_USE_ZEND_MM + if (CURLE_OK != curl_global_init_mem(CURL_GLOBAL_ALL, + http_curl_malloc, + http_curl_free, + http_curl_realloc, + http_curl_strdup, + http_curl_calloc)) { + return FAILURE; + } +# endif /* HTTP_CURL_USE_ZEND_MM */ +# if LIBCURL_VERSION_NUM >= 0x070a05 REGISTER_LONG_CONSTANT("HTTP_AUTH_BASIC", CURLAUTH_BASIC, CONST_CS | CONST_PERSISTENT); REGISTER_LONG_CONSTANT("HTTP_AUTH_DIGEST", CURLAUTH_DIGEST, CONST_CS | CONST_PERSISTENT); REGISTER_LONG_CONSTANT("HTTP_AUTH_NTLM", CURLAUTH_NTLM, CONST_CS | CONST_PERSISTENT); -#endif +# endif /* LIBCURL_VERSION_NUM */ +#endif /* HTTP_HAVE_CURL */ #ifdef ZEND_ENGINE_2 HTTP_REGISTER_CLASS(HTTPi, httpi, NULL, ZEND_ACC_FINAL_CLASS); @@ -460,6 +486,9 @@ PHP_MINIT_FUNCTION(http) PHP_MSHUTDOWN_FUNCTION(http) { UNREGISTER_INI_ENTRIES(); +#ifdef HTTP_HAVE_CURL + curl_global_cleanup(); +#endif return SUCCESS; } /* }}} */ @@ -505,16 +534,37 @@ PHP_RSHUTDOWN_FUNCTION(http) /* {{{ PHP_MINFO_FUNCTION */ PHP_MINFO_FUNCTION(http) { - php_info_print_table_start(); - php_info_print_table_header(2, "Extended HTTP support", "enabled"); - php_info_print_table_row(2, "Version:", PHP_EXT_HTTP_VERSION); - php_info_print_table_row(2, "cURL convenience functions:", +#ifdef ZEND_ENGINE_2 +# define HTTP_FUNC_AVAIL(CLASS) "procedural, object oriented (class " CLASS ")" +#else +# define HTTP_FUNC_AVAIL(CLASS) "procedural" +#endif + #ifdef HTTP_HAVE_CURL - "enabled" +# define HTTP_CURL_VERSION curl_version() +# ifdef ZEND_ENGINE_2 +# define HTTP_CURL_AVAIL(CLASS) "procedural, object oriented (class " CLASS ")" +# else +# define HTTP_CURL_AVAIL(CLASS) "procedural" +# endif #else - "disabled" +# define HTTP_CURL_VERSION "libcurl not available" +# define HTTP_CURL_AVAIL(CLASS) "libcurl not available" #endif - ); + + char full_version_string[1024] = {0}; + snprintf(full_version_string, 1023, "%s (%s)", PHP_EXT_HTTP_VERSION, HTTP_CURL_VERSION); + + php_info_print_table_start(); + php_info_print_table_row(2, "Extended HTTP support", "enabled"); + php_info_print_table_row(2, "Extension Version:", full_version_string); + php_info_print_table_end(); + + php_info_print_table_start(); + php_info_print_table_header(2, "Functionality", "Availability"); + php_info_print_table_row(2, "Miscellaneous Utilities:", HTTP_FUNC_AVAIL("HTTPi")); + php_info_print_table_row(2, "Extended HTTP Responses:", HTTP_FUNC_AVAIL("HTTPi_Response")); + php_info_print_table_row(2, "Extended HTTP Requests:", HTTP_CURL_AVAIL("HTTPi_Request")); php_info_print_table_end(); DISPLAY_INI_ENTRIES();