X-Git-Url: https://git.m6w6.name/?p=m6w6%2Fext-http;a=blobdiff_plain;f=http_request_method_api.c;h=a2197c6425324305a4bfb6b15c10d14b48bb2048;hp=57636d088b2b065e7e050bc3015a6859803ea2cf;hb=100b5ff381fe93e7ac4d7b0ea68f9b7256615e68;hpb=36fa8b05be7aaf8e7f9e503c3e82733022500c03 diff --git a/http_request_method_api.c b/http_request_method_api.c index 57636d0..a2197c6 100644 --- a/http_request_method_api.c +++ b/http_request_method_api.c @@ -28,6 +28,7 @@ # include "php_http_request_object.h" #endif +#include "missing.h" #include "phpstr/phpstr.h" ZEND_EXTERN_MODULE_GLOBALS(http); @@ -154,29 +155,28 @@ PHP_HTTP_API unsigned long _http_request_method_exists(zend_bool by_name, unsign /* }}} */ /* {{{ unsigned long http_request_method_register(char *) */ -PHP_HTTP_API unsigned long _http_request_method_register(const char *method_name TSRMLS_DC) +PHP_HTTP_API unsigned long _http_request_method_register(const char *method_name, size_t method_name_len TSRMLS_DC) { zval array; char *http_method, *method; - int i, method_len = strlen(method_name); - unsigned long meth_num = HTTP_G(request).methods.custom.nNextFreeElement + HTTP_MAX_REQUEST_METHOD; + unsigned long i, meth_num = HTTP_G(request).methods.custom.nNextFreeElement + HTTP_MAX_REQUEST_METHOD; - method = emalloc(method_len + 1); - for (i = 0; i < method_len; ++i) { + method = emalloc(method_name_len + 1); + for (i = 0; i < method_name_len; ++i) { method[i] = toupper(method_name[i]); } - method[method_len] = '\0'; + method[method_name_len] = '\0'; - Z_ARRVAL(array) = &HTTP_G(request).methods.custom; - add_next_index_stringl(&array, method, method_len, 0); + INIT_ZARR(array, &HTTP_G(request).methods.custom); + add_next_index_stringl(&array, method, method_name_len, 0); - method_len = spprintf(&http_method, 0, "HTTP_METH_%s", method); - zend_register_long_constant(http_method, method_len + 1, meth_num, CONST_CS, http_module_number TSRMLS_CC); + method_name_len = spprintf(&http_method, 0, "HTTP_METH_%s", method); + zend_register_long_constant(http_method, method_name_len + 1, meth_num, CONST_CS, http_module_number TSRMLS_CC); efree(http_method); -#if defined(ZEND_ENGINE_2) && defined(HTTP_HAVE_CURL) - method_len = spprintf(&http_method, 0, "METH_%s", method); - zend_declare_class_constant_long(http_request_object_ce, http_method, method_len, meth_num TSRMLS_CC); +#if defined(ZEND_ENGINE_2) && defined(HTTP_HAVE_CURL) && !defined(WONKY) + method_name_len = spprintf(&http_method, 0, "METH_%s", method); + zend_declare_class_constant_long(http_request_object_ce, http_method, method_name_len, meth_num TSRMLS_CC); efree(http_method); #endif @@ -196,7 +196,7 @@ PHP_HTTP_API STATUS _http_request_method_unregister(unsigned long method TSRMLS_ return FAILURE; } -#if defined(ZEND_ENGINE_2) && defined(HTTP_HAVE_CURL) +#if defined(ZEND_ENGINE_2) && defined(HTTP_HAVE_CURL) && !defined(WONKY) method_len = spprintf(&http_method, 0, "METH_%s", Z_STRVAL_PP(zmethod)); if ((SUCCESS != zend_hash_del(&http_request_object_ce->constants_table, http_method, method_len + 1))) { http_error_ex(HE_NOTICE, HTTP_E_REQUEST_METHOD, "Could not unregister request method: HttpRequest::%s", http_method);