]> granicus.if.org Git - apache/commitdiff
This patch eliminates the wasteful run-time conversion of method names from
authorJustin Erenkrantz <jerenkrantz@apache.org>
Wed, 19 Sep 2001 05:52:42 +0000 (05:52 +0000)
committerJustin Erenkrantz <jerenkrantz@apache.org>
Wed, 19 Sep 2001 05:52:42 +0000 (05:52 +0000)
strings to numbers in places where the methods are known at compile
time.

(Justin fixed the va_end() call to be correct.)

Submitted by: Brian Pane <bpane@pacbell.net>
Reviewed by: Justin Erenkrantz

git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@91078 13f79535-47bb-0310-9956-ffa450edef68

CHANGES
include/http_request.h
modules/http/http_request.c
modules/mappers/mod_negotiation.c
server/core.c

diff --git a/CHANGES b/CHANGES
index f81f646ecdc7126a6f24ce9c41d8af78eeb14df8..bd85b53c9a8f9c249376796875ea23197457fdd4 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -1,5 +1,9 @@
 Changes with Apache 2.0.26-dev
 
+  *) Eliminate the wasteful run-time conversion of method names from strings 
+     to numbers in places where the methods are known at compile time.  
+     [Brian Pane <bpane@pacbell.net>]
+
   *) Turn the worker MPM's queue into a LIFO.  This may
      improve cache-hit performance under some conditions.
      [Aaron Bannert <aaron@clove.org>]
index f532cd0491fb83f50c1c6ea5264608d885f3e3b4..f1963eb20c9c29fc6aa9872b9d4ba5081af6b4b1 100644 (file)
@@ -261,6 +261,25 @@ AP_DECLARE(void) ap_update_mtime(request_rec *r, apr_time_t dependency_mtime);
  */
 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, terminated with a value of -1
+ *                (e.g., "M_GET, M_POST, M_OPTIONS, -1")
+ * @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 296fffb8d73a9cc099eb8ed9ffedc370f8ad38a1..4dbbc788b224c5c2a6bb3b1c13199dd11b522585 100644 (file)
@@ -490,3 +490,27 @@ AP_DECLARE(void) ap_allow_methods(request_rec *r, int reset, ...)
        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(methods);
+
+    r->allowed_methods->method_mask |= mask;
+}
index 7e910c94cc8ee0ce1e4ad947b2e13228f98cde31..bde4dab442112195cc958d0f7b0aec99d8910d6a 100644 (file)
@@ -2768,7 +2768,7 @@ static int handle_map_file(request_rec *r)
         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;
         }
index 241ad239e58ca953e74efcbfeeee0b82303b992c..f52b5e024ae5489096355395398d2062939f51c6 100644 (file)
@@ -2676,7 +2676,7 @@ static int default_handler(request_rec *r)
     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;