This patch eliminates some run-time conversion of method names to
numbers (something that I noticed while looking through function call
profiles).
--Brian
Index: include/http_request.h
===================================================================
RCS file: /home/cvspublic/httpd-2.0/include/http_request.h,v
retrieving revision 1.36
diff -u -r1.36 http_request.h
--- include/http_request.h 2001/08/31 01:38:06 1.36
+++ include/http_request.h 2001/09/06 15:48:00
@@ -261,6 +261,24 @@
*/
AP_DECLARE(void) ap_allow_methods(request_rec *r, int reset, ...);
+/**
+ * Add one or more methods to the list permitted to access the resource.
+ * Usually executed by the content handler before the response header is
+ * sent, but sometimes invoked at an earlier phase if a module knows it
+ * can set the list authoritatively. Note that the methods are ADDED
+ * to any already permitted unless the reset flag is non-zero. The
+ * list is used to generate the Allow response header field when it
+ * is needed.
+ * @param r The pointer to the request identifying the resource.
+ * @param reset Boolean flag indicating whether this list should
+ * completely replace any current settings.
+ * @param ... A list of method identifiers, from the "M_" series
+ * defined in httpd.h (M_GET, M_POST, etc)
+ * @return None.
+ * @deffunc void ap_allow_standard_methods(request_rec *r, int reset, ...)
+ */
+AP_DECLARE(void) ap_allow_standard_methods(request_rec *r, int reset, ...);
+
#define MERGE_ALLOW 0
#define REPLACE_ALLOW 1
Index: modules/http/http_request.c
===================================================================
RCS file: /home/cvspublic/httpd-2.0/modules/http/http_request.c,v
retrieving revision 1.113
diff -u -r1.113 http_request.c
--- modules/http/http_request.c 2001/08/31 03:49:42 1.113
+++ modules/http/http_request.c 2001/09/06 15:48:00
@@ -490,3 +490,28 @@
ap_method_list_add(r->allowed_methods, method);
}
}
+
+
+AP_DECLARE(void) ap_allow_standard_methods(request_rec *r, int reset, ...)
+{
+ int method;
+ va_list methods;
+ apr_int64_t mask;
+
+ /*
+ * Get rid of any current settings if requested; not just the
+ * well-known methods but any extensions as well.
+ */
+ if (reset) {
+ ap_clear_method_list(r->allowed_methods);
+ }
+
+ mask = 0;
+ va_start(methods, reset);
+ while ((method = va_arg(methods, int)) != -1) {
+ mask |= (AP_METHOD_BIT << method);
+ }
+ va_end;
+
+ r->allowed_methods->method_mask |= mask;
+}
Index: server/core.c
===================================================================
RCS file: /home/cvspublic/httpd-2.0/server/core.c,v
retrieving revision 1.58
diff -u -r1.58 core.c
--- server/core.c 2001/08/31 13:45:16 1.58
+++ server/core.c 2001/09/06 15:48:02
@@ -2991,7 +2991,7 @@
bld_content_md5 = (d->content_md5 & 1)
&& r->output_filters->frec->ftype != AP_FTYPE_CONTENT;
- ap_allow_methods(r, MERGE_ALLOW, "GET", "OPTIONS", "POST", NULL);
+ ap_allow_standard_methods(r, MERGE_ALLOW, M_GET, M_OPTIONS, M_POST,
-1);
if ((errstatus = ap_discard_request_body(r)) != OK) {
return errstatus;
Index: modules/mappers/mod_negotiation.c
===================================================================
RCS file: /home/cvspublic/httpd-2.0/modules/mappers/mod_negotiation.c,v
retrieving revision 1.81
diff -u -r1.81 mod_negotiation.c
--- modules/mappers/mod_negotiation.c 2001/08/30 13:37:16 1.81
+++ modules/mappers/mod_negotiation.c 2001/09/06 15:48:04
@@ -2768,7 +2768,7 @@
apr_bucket_brigade *bb;
apr_bucket *e;
- ap_allow_methods(r, REPLACE_ALLOW, "GET", "OPTIONS", "POST", NULL);
+ ap_allow_standard_methods(r, REPLACE_ALLOW, M_GET, M_OPTIONS,
M_POST, -1);
if ((res = ap_discard_request_body(r)) != OK) {
return res;
}