- unified cache_api function names
[m6w6/ext-http] / http.c
diff --git a/http.c b/http.c
index 3902443bde951d6a5d8e861079c6947cdf55e90f..494a1aae7a6d198c6808a320a9623cc487b500e3 100644 (file)
--- a/http.c
+++ b/http.c
@@ -27,6 +27,8 @@
 #      include <curl/curl.h>
 #endif
 
+#include <ctype.h>
+
 #include "php.h"
 #include "php_ini.h"
 #include "ext/standard/info.h"
@@ -111,7 +113,7 @@ function_entry http_functions[] = {
 #ifndef ZEND_ENGINE_2
        PHP_FE(http_build_query, NULL)
 #endif
-       PHP_FE(ob_httpetaghandler, NULL)
+       PHP_FE(ob_etaghandler, NULL)
        {NULL, NULL, NULL}
 };
 /* }}} */
@@ -141,15 +143,14 @@ 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)
+/* {{{ void _http_init_globals(zend_http_globals *) */
+static void _http_init_globals(zend_http_globals *http_globals)
 {
        http_globals->etag_started = 0;
        http_globals->ctype = NULL;
        http_globals->etag  = NULL;
        http_globals->lmod  = 0;
 #ifdef HTTP_HAVE_CURL
-       phpstr_init_ex(&http_globals->curlbuf, HTTP_CURLBUF_SIZE, 0);
 #      if LIBCURL_VERSION_NUM < 0x070c00
        memset(&http_globals->curlerr, 0, sizeof(http_globals->curlerr));
 #      endif
@@ -163,14 +164,24 @@ static void php_http_init_globals(zend_http_globals *http_globals)
 #define http_check_allowed_methods(m, l) _http_check_allowed_methods((m), (l) TSRMLS_CC)
 static inline void _http_check_allowed_methods(char *methods, int length TSRMLS_DC)
 {
-       if (length && SG(request_info).request_method && (!strstr(methods, SG(request_info).request_method))) {
-               char *allow_header = emalloc(length + sizeof("Allow: "));
-               sprintf(allow_header, "Allow: %s", methods);
-               http_send_header(allow_header);
-               efree(allow_header);
-               http_send_status(405);
-               zend_bailout();
+       char *found, *header;
+
+       if (!length || !SG(request_info).request_method) {
+               return;
        }
+
+       if (    (found = strstr(methods, SG(request_info).request_method)) &&
+                       (found == SG(request_info).request_method || !isalpha(found[-1])) &&
+                       (!isalpha(found[strlen(SG(request_info).request_method) + 1]))) {
+               return;
+       }
+
+       header = emalloc(length + sizeof("Allow: "));
+       sprintf(header, "Allow: %s", methods);
+       http_send_header(header);
+       efree(header);
+       http_send_status(405);
+       zend_bailout();
 }
 /* }}} */
 
@@ -211,7 +222,7 @@ static void *http_curl_calloc(size_t n, size_t s)   { return ecalloc(n, s); }
 /* {{{ PHP_MINIT_FUNCTION */
 PHP_MINIT_FUNCTION(http)
 {
-       ZEND_INIT_MODULE_GLOBALS(http, php_http_init_globals, NULL);
+       ZEND_INIT_MODULE_GLOBALS(http, _http_init_globals, NULL);
        REGISTER_INI_ENTRIES();
 
 #ifdef HTTP_HAVE_CURL
@@ -246,7 +257,6 @@ PHP_MSHUTDOWN_FUNCTION(http)
 {
        UNREGISTER_INI_ENTRIES();
 #ifdef HTTP_HAVE_CURL
-       phpstr_dtor(&HTTP_G(curlbuf));
        curl_global_cleanup();
 #endif
        return SUCCESS;
@@ -282,7 +292,6 @@ PHP_RSHUTDOWN_FUNCTION(http)
 #      if LIBCURL_VERSION_NUM < 0x070c00
        memset(&HTTP_G(curlerr), 0, sizeof(HTTP_G(curlerr)));
 #      endif
-       phpstr_dtor(&HTTP_G(curlbuf));
 #endif
 
        return SUCCESS;
@@ -293,7 +302,7 @@ PHP_RSHUTDOWN_FUNCTION(http)
 PHP_MINFO_FUNCTION(http)
 {
 #ifdef ZEND_ENGINE_2
-#      define HTTP_FUNC_AVAIL(CLASS) "procedural, object oriented (class " CLASS ")"
+#      define HTTP_FUNC_AVAIL(CLASS) "procedural, object oriented (" CLASS ")"
 #else
 #      define HTTP_FUNC_AVAIL(CLASS) "procedural"
 #endif
@@ -301,7 +310,7 @@ PHP_MINFO_FUNCTION(http)
 #ifdef HTTP_HAVE_CURL
 #      define HTTP_CURL_VERSION curl_version()
 #      ifdef ZEND_ENGINE_2
-#              define HTTP_CURL_AVAIL(CLASS) "procedural, object oriented (class " CLASS ")"
+#              define HTTP_CURL_AVAIL(CLASS) "procedural, object oriented (" CLASS ")"
 #      else
 #              define HTTP_CURL_AVAIL(CLASS) "procedural"
 #      endif
@@ -320,7 +329,7 @@ PHP_MINFO_FUNCTION(http)
 
        php_info_print_table_start();
        php_info_print_table_header(2, "Functionality",            "Availability");
-       php_info_print_table_row(2,    "Miscellaneous Utilities:", HTTP_FUNC_AVAIL("HttpUtil"));
+       php_info_print_table_row(2,    "Miscellaneous Utilities:", HTTP_FUNC_AVAIL("HttpUtil, HttpMessage"));
        php_info_print_table_row(2,    "Extended HTTP Responses:", HTTP_FUNC_AVAIL("HttpResponse"));
        php_info_print_table_row(2,    "Extended HTTP Requests:",  HTTP_CURL_AVAIL("HttpRequest"));
        php_info_print_table_end();