]> granicus.if.org Git - apache/commitdiff
* As per niq's comment, better destinct the types of idempotence.
authorRuediger Pluem <rpluem@apache.org>
Tue, 12 Feb 2008 20:51:08 +0000 (20:51 +0000)
committerRuediger Pluem <rpluem@apache.org>
Tue, 12 Feb 2008 20:51:08 +0000 (20:51 +0000)
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@627097 13f79535-47bb-0310-9956-ffa450edef68

modules/proxy/mod_proxy_ajp.c

index fa09ae895c1b390a7a2ae6ce6315ef10307541b9..b1c0615bd1d15e852abb00f3a6e2462aa1686f42 100644 (file)
@@ -89,15 +89,12 @@ static int proxy_ajp_canon(request_rec *r, char *url)
     return OK;
 }
 
+#define METHOD_NON_IDEMPOTENT       0
+#define METHOD_IDEMPOTENT           1
+#define METHOD_IDEMPOTENT_WITH_ARGS 2
+
 static int is_idempotent(request_rec *r)
 {
-    /*
-     * If the request has arguments it might not be idempotent as it might have
-     * side-effects.
-     */
-    if (r->args) {
-        return 0;
-    }
     /*
      * RFC2616 (9.1.2): GET, HEAD, PUT, DELETE, OPTIONS, TRACE are considered
      * idempotent. Hint: HEAD requests use M_GET as method number as well.
@@ -108,10 +105,18 @@ static int is_idempotent(request_rec *r)
         case M_PUT:
         case M_OPTIONS:
         case M_TRACE:
-            return 1;
+            /*
+             * If the request has arguments it might have side-effects and thus
+             * it might be undesirable to resent it to a backend again
+             * automatically.
+             */
+            if (r->args) {
+                return METHOD_IDEMPOTENT_WITH_ARGS;
+            }
+            return METHOD_IDEMPOTENT;
         /* Everything else is not considered idempotent. */
         default:
-            return 0;
+            return METHOD_NON_IDEMPOTENT;
     }
 }
 
@@ -193,7 +198,7 @@ static int ap_proxy_ajp_request(apr_pool_t *p, request_rec *r,
              * case we can dare to retry it with a different worker if we are
              * a balancer member.
              */
-            if (is_idempotent(r)) {
+            if (is_idempotent(r) == METHOD_IDEMPOTENT) {
                 return HTTP_SERVICE_UNAVAILABLE;
             }
             return HTTP_INTERNAL_SERVER_ERROR;
@@ -294,7 +299,7 @@ static int ap_proxy_ajp_request(apr_pool_t *p, request_rec *r,
          * again) and the method is idempotent. In this case we can dare to
          * retry it with a different worker if we are a balancer member.
          */
-        if ((bufsiz == 0) && is_idempotent(r)) {
+        if ((bufsiz == 0) && (is_idempotent(r) == METHOD_IDEMPOTENT)) {
             return HTTP_SERVICE_UNAVAILABLE;
         }
         return HTTP_INTERNAL_SERVER_ERROR;