- INIT_ZARR(array, &HTTP_G(request).methods.custom);
- add_next_index_stringl(&array, method, method_len, 0);
+ method = emalloc(method_name_len + 1);
+ mconst = emalloc(method_name_len + 1);
+ for (i = 0; i < method_name_len; ++i) {
+ switch (method_name[i])
+ {
+ case '-':
+ method[i] = '-';
+ mconst[i] = '_';
+ break;
+
+ default:
+ if (!isalnum(method_name[i])) {
+ efree(method);
+ efree(mconst);
+ http_error_ex(HE_WARNING, HTTP_E_REQUEST_METHOD, "Request method contains illegal characters (%s)", method_name);
+ return 0;
+ }
+ mconst[i] = method[i] = toupper(method_name[i]);
+ break;
+ }
+ }
+ method[method_name_len] = '\0';
+ mconst[method_name_len] = '\0';
+
+ ptr = erealloc(ptr, sizeof(http_request_method_entry *) * (HTTP_G->request.methods.custom.count + 1));
+ HTTP_G->request.methods.custom.entries = ptr;
+ ptr[HTTP_G->request.methods.custom.count] = emalloc(sizeof(http_request_method_entry));
+ ptr[HTTP_G->request.methods.custom.count]->name = method;
+ ptr[HTTP_G->request.methods.custom.count]->cnst = mconst;
+ meth_num = HTTP_CUSTOM_REQUEST_METHOD_START + HTTP_G->request.methods.custom.count++;