X-Git-Url: https://git.m6w6.name/?p=m6w6%2Fext-http;a=blobdiff_plain;f=http.c;h=32d9e2aa85554197c93e07f7c033579eb0eaedd2;hp=b606bc3813c440ff726ec336ea80a75a5d063cac;hb=ef65a3f954762e08684b70b5a2e407edfa9c293b;hpb=a19a05825d04d634834f7898ec1a5247fdd6095c diff --git a/http.c b/http.c index b606bc3..32d9e2a 100644 --- a/http.c +++ b/http.c @@ -15,13 +15,18 @@ /* $Id$ */ -#define _WINSOCKAPI_ -#define ZEND_INCLUDE_FULL_WINDOWS_HEADERS #ifdef HAVE_CONFIG_H # include "config.h" #endif +#ifdef HTTP_HAVE_CURL +# ifdef PHP_WIN32 +# include +# endif +# include +#endif + #include "php.h" #include "php_ini.h" #include "snprintf.h" @@ -35,20 +40,13 @@ #include "php_http.h" #include "php_http_api.h" #include "php_http_curl_api.h" +#include "php_http_std_defs.h" #ifdef ZEND_ENGINE_2 # include "ext/standard/php_http.h" #endif #ifdef HTTP_HAVE_CURL - -# ifdef PHP_WIN32 -# include -# include -# endif - -# include - /* {{{ ARG_INFO */ # ifdef ZEND_BEGIN_ARG_INFO ZEND_BEGIN_ARG_INFO(http_request_info_ref_3, 0) @@ -310,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) @@ -337,7 +339,8 @@ zend_function_entry httpi_request_class_methods[] = { PHP_ME(HTTPi_Request, send, NULL, ZEND_ACC_PUBLIC) PHP_ME(HTTPi_Request, getResponseData, NULL, ZEND_ACC_PUBLIC) - PHP_ME(HTTPi_Request, getResponseHeaders, NULL, ZEND_ACC_PUBLIC) + PHP_ME(HTTPi_Request, getResponseHeader, NULL, ZEND_ACC_PUBLIC) + PHP_ME(HTTPi_Request, getResponseCode, NULL, ZEND_ACC_PUBLIC) PHP_ME(HTTPi_Request, getResponseBody, NULL, ZEND_ACC_PUBLIC) PHP_ME(HTTPi_Request, getResponseInfo, NULL, ZEND_ACC_PUBLIC) @@ -368,6 +371,12 @@ zend_module_entry http_module_entry = { }; /* }}} */ + +static void free_to_free(void *s) +{ + efree(*(char **)s); +} + /* {{{ php_http_init_globals(zend_http_globals *) */ static void php_http_init_globals(zend_http_globals *http_globals) { @@ -380,6 +389,7 @@ static void php_http_init_globals(zend_http_globals *http_globals) http_globals->curlbuf.used = 0; http_globals->curlbuf.free = 0; http_globals->curlbuf.size = 0; + zend_llist_init(&http_globals->to_free, sizeof(char *), free_to_free, 0); #endif http_globals->allowed_methods = NULL; } @@ -408,7 +418,19 @@ PHP_INI_MH(update_allowed_methods) } PHP_INI_BEGIN() - STD_PHP_INI_ENTRY("http.allowed_methods", "OPTIONS,GET,HEAD,POST,PUT,DELETE,TRACE,CONNECT", PHP_INI_ALL, update_allowed_methods, allowed_methods, zend_http_globals, http_globals) + STD_PHP_INI_ENTRY("http.allowed_methods", + /* HTTP 1.1 */ + "GET, HEAD, POST, PUT, DELETE, OPTIONS, TRACE, CONNECT, " + /* WebDAV - RFC 2518 * / + "PROPFIND, PROPPATCH, MKCOL, COPY, MOVE, LOCK, UNLOCK, " + /* WebDAV Versioning - RFC 3253 * / + "VERSION-CONTROL, REPORT, CHECKOUT, CHECKIN, UNCHECKOUT, " + "MKWORKSPACE, UPDATE, LABEL, MERGE, BASELINE-CONTROL, MKACTIVITY, " + /* WebDAV Access Control - RFC 3744 * / + "ACL, " + /* END */ + , + PHP_INI_ALL, update_allowed_methods, allowed_methods, zend_http_globals, http_globals) PHP_INI_END() /* }}} */ @@ -470,6 +492,7 @@ PHP_RSHUTDOWN_FUNCTION(http) efree(HTTP_G(ctype)); HTTP_G(ctype) = NULL; } + #ifdef HTTP_HAVE_CURL if (HTTP_G(curlbuf).data) { efree(HTTP_G(curlbuf).data); @@ -478,6 +501,7 @@ PHP_RSHUTDOWN_FUNCTION(http) HTTP_G(curlbuf).free = 0; } #endif + return SUCCESS; } /* }}} */ @@ -485,16 +509,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();