- (non-)ZTS fixes
[m6w6/ext-http] / http_request_method_api.c
index 1d73ddda5b4a447acea1b2f7ea54ebdfe4d9485a..713fc5a1e8a0d00eadd1a1a8e5b9dcc588ffdf9f 100644 (file)
@@ -103,6 +103,20 @@ PHP_RINIT_FUNCTION(http_request_method)
 {
        HTTP_G->request.methods.custom.entries = ecalloc(1, sizeof(http_request_method_entry *));
        
+       if (HTTP_G->request.methods.custom.ini && *HTTP_G->request.methods.custom.ini) {
+               HashPosition pos;
+               HashTable methods;
+               zval **data;
+       
+               zend_hash_init(&methods, 0, NULL, ZVAL_PTR_DTOR, 0);
+               http_parse_params(HTTP_G->request.methods.custom.ini, HTTP_PARAMS_DEFAULT, &methods);
+               FOREACH_HASH_VAL(pos, &methods, data) {
+                       if (Z_TYPE_PP(data) == IS_STRING) {
+                               http_request_method_register(Z_STRVAL_PP(data), Z_STRLEN_PP(data));
+                       }
+               }
+               zend_hash_destroy(&methods);
+       }
        return SUCCESS;
 }
 
@@ -246,7 +260,7 @@ PHP_HTTP_API STATUS _http_request_method_unregister(int method TSRMLS_DC)
        if (    (HTTP_CUSTOM_REQUEST_METHOD(method) < 0) ||
                        (HTTP_CUSTOM_REQUEST_METHOD(method) > HTTP_G->request.methods.custom.count) ||
                        (!ptr[HTTP_CUSTOM_REQUEST_METHOD(method)])) {
-               http_error_ex(HE_NOTICE, HTTP_E_REQUEST_METHOD, "Custom request method with id %lu does not exist", method);
+               http_error_ex(HE_NOTICE, HTTP_E_REQUEST_METHOD, "Custom request method with id %d does not exist", method);
                return FAILURE;
        }