- adjust ini entry names to those of the globals struct
[m6w6/ext-http] / http_request_method_api.c
index 498dbe2f54b6644cc6fa0b9231c84dd4696fe35e..9e428d15ce9ff37960e69f786daad2cca2416a4e 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, &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;
 }
 
@@ -190,12 +204,11 @@ PHP_HTTP_API int _http_request_method_register(const char *method_name, int meth
        method = emalloc(method_name_len + 1);
        mconst = emalloc(method_name_len + 1);
        for (i = 0; i < method_name_len; ++i) {
-               switch (method_name[i])
-               {
+               switch (method_name[i]) {
                        case '-':
                                method[i] = '-';
                                mconst[i] = '_';
-                       break;
+                               break;
                        
                        default:
                                if (!isalnum(method_name[i])) {
@@ -205,7 +218,7 @@ PHP_HTTP_API int _http_request_method_register(const char *method_name, int meth
                                        return 0;
                                }
                                mconst[i] = method[i] = toupper(method_name[i]);
-                       break;
+                               break;
                }
        }
        method[method_name_len] = '\0';