altarch-user / rpms / httpd

Forked from rpms/httpd 2 years ago
Clone

Blame SOURCES/httpd-2.4.6-r1681114.patch

cce4bc
diff --git a/modules/http/http_request.c b/modules/http/http_request.c
cce4bc
index cdfec8b..c97dc77 100644
cce4bc
--- a/modules/http/http_request.c
cce4bc
+++ b/modules/http/http_request.c
cce4bc
@@ -73,19 +73,22 @@ static void update_r_in_filters(ap_filter_t *f,
cce4bc
     }
cce4bc
 }
cce4bc
 
cce4bc
-AP_DECLARE(void) ap_die(int type, request_rec *r)
cce4bc
+static void ap_die_r(int type, request_rec *r, int recursive_error)
cce4bc
 {
cce4bc
-    int error_index = ap_index_of_response(type);
cce4bc
-    char *custom_response = ap_response_code_string(r, error_index);
cce4bc
-    int recursive_error = 0;
cce4bc
+    char *custom_response;
cce4bc
     request_rec *r_1st_err = r;
cce4bc
 
cce4bc
-    if (type == AP_FILTER_ERROR) {
cce4bc
+    if (type == OK || type == DONE){
cce4bc
+        ap_finalize_request_protocol(r);
cce4bc
+        return;
cce4bc
+    }
cce4bc
+
cce4bc
+    if (!ap_is_HTTP_VALID_RESPONSE(type)) {
cce4bc
         ap_filter_t *next;
cce4bc
 
cce4bc
         /*
cce4bc
          * Check if we still have the ap_http_header_filter in place. If
cce4bc
-         * this is the case we should not ignore AP_FILTER_ERROR here because
cce4bc
+         * this is the case we should not ignore the error here because
cce4bc
          * it means that we have not sent any response at all and never
cce4bc
          * will. This is bad. Sent an internal server error instead.
cce4bc
          */
cce4bc
@@ -99,8 +102,14 @@ AP_DECLARE(void) ap_die(int type, request_rec *r)
cce4bc
          * next->frec == ap_http_header_filter
cce4bc
          */
cce4bc
         if (next) {
cce4bc
-            ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r, APLOGNO(01579)
cce4bc
-                          "Custom error page caused AP_FILTER_ERROR");
cce4bc
+            if (type != AP_FILTER_ERROR) {
cce4bc
+                ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r, APLOGNO(01579)
cce4bc
+                              "Invalid response status %i", type);
cce4bc
+            }
cce4bc
+            else {
cce4bc
+                ap_log_rerror(APLOG_MARK, APLOG_DEBUG, 0, r, APLOGNO(02831)
cce4bc
+                              "Response from AP_FILTER_ERROR");
cce4bc
+            }
cce4bc
             type = HTTP_INTERNAL_SERVER_ERROR;
cce4bc
         }
cce4bc
         else {
cce4bc
@@ -108,20 +117,13 @@ AP_DECLARE(void) ap_die(int type, request_rec *r)
cce4bc
         }
cce4bc
     }
cce4bc
 
cce4bc
-    if (type == DONE) {
cce4bc
-        ap_finalize_request_protocol(r);
cce4bc
-        return;
cce4bc
-    }
cce4bc
-
cce4bc
     /*
cce4bc
      * The following takes care of Apache redirects to custom response URLs
cce4bc
      * Note that if we are already dealing with the response to some other
cce4bc
      * error condition, we just report on the original error, and give up on
cce4bc
      * any attempt to handle the other thing "intelligently"...
cce4bc
      */
cce4bc
-    if (r->status != HTTP_OK) {
cce4bc
-        recursive_error = type;
cce4bc
-
cce4bc
+    if (recursive_error != HTTP_OK) {
cce4bc
         while (r_1st_err->prev && (r_1st_err->prev->status != HTTP_OK))
cce4bc
             r_1st_err = r_1st_err->prev;  /* Get back to original error */
cce4bc
 
cce4bc
@@ -140,6 +142,10 @@ AP_DECLARE(void) ap_die(int type, request_rec *r)
cce4bc
         }
cce4bc
 
cce4bc
         custom_response = NULL; /* Do NOT retry the custom thing! */
cce4bc
+    } else {
cce4bc
+        int error_index = ap_index_of_response(type);
cce4bc
+        custom_response = ap_response_code_string(r, error_index);
cce4bc
+        recursive_error = 0;
cce4bc
     }
cce4bc
 
cce4bc
     r->status = type;
cce4bc
@@ -216,6 +222,11 @@ AP_DECLARE(void) ap_die(int type, request_rec *r)
cce4bc
     ap_send_error_response(r_1st_err, recursive_error);
cce4bc
 }
cce4bc
 
cce4bc
+AP_DECLARE(void) ap_die(int type, request_rec *r)
cce4bc
+{
cce4bc
+    ap_die_r(type, r, r->status);
cce4bc
+}
cce4bc
+
cce4bc
 static void check_pipeline(conn_rec *c)
cce4bc
 {
cce4bc
     if (c->keepalive != AP_CONN_CLOSE) {
cce4bc
@@ -337,18 +348,7 @@ void ap_process_async_request(request_rec *r)
cce4bc
     apr_thread_mutex_unlock(r->invoke_mtx);
cce4bc
 #endif
cce4bc
 
cce4bc
-    if (access_status == DONE) {
cce4bc
-        /* e.g., something not in storage like TRACE */
cce4bc
-        access_status = OK;
cce4bc
-    }
cce4bc
-
cce4bc
-    if (access_status == OK) {
cce4bc
-        ap_finalize_request_protocol(r);
cce4bc
-    }
cce4bc
-    else {
cce4bc
-        r->status = HTTP_OK;
cce4bc
-        ap_die(access_status, r);
cce4bc
-    }
cce4bc
+    ap_die_r(access_status, r, HTTP_OK);
cce4bc
 
cce4bc
     ap_process_request_after_handler(r);
cce4bc
 }
cce4bc
@@ -631,8 +631,8 @@ AP_DECLARE(void) ap_internal_fast_redirect(request_rec *rr, request_rec *r)
cce4bc
 
cce4bc
 AP_DECLARE(void) ap_internal_redirect(const char *new_uri, request_rec *r)
cce4bc
 {
cce4bc
-    request_rec *new = internal_internal_redirect(new_uri, r);
cce4bc
     int access_status;
cce4bc
+    request_rec *new = internal_internal_redirect(new_uri, r);
cce4bc
 
cce4bc
     AP_INTERNAL_REDIRECT(r->uri, new_uri);
cce4bc
 
cce4bc
@@ -648,12 +648,7 @@ AP_DECLARE(void) ap_internal_redirect(const char *new_uri, request_rec *r)
cce4bc
             access_status = ap_invoke_handler(new);
cce4bc
         }
cce4bc
     }
cce4bc
-    if (access_status == OK) {
cce4bc
-        ap_finalize_request_protocol(new);
cce4bc
-    }
cce4bc
-    else {
cce4bc
-        ap_die(access_status, new);
cce4bc
-    }
cce4bc
+    ap_die(access_status, new);
cce4bc
 }
cce4bc
 
cce4bc
 /* This function is designed for things like actions or CGI scripts, when
cce4bc
@@ -674,15 +669,9 @@ AP_DECLARE(void) ap_internal_redirect_handler(const char *new_uri, request_rec *
cce4bc
         ap_set_content_type(new, r->content_type);
cce4bc
     access_status = ap_process_request_internal(new);
cce4bc
     if (access_status == OK) {
cce4bc
-        if ((access_status = ap_invoke_handler(new)) != 0) {
cce4bc
-            ap_die(access_status, new);
cce4bc
-            return;
cce4bc
-        }
cce4bc
-        ap_finalize_request_protocol(new);
cce4bc
-    }
cce4bc
-    else {
cce4bc
-        ap_die(access_status, new);
cce4bc
+        access_status = ap_invoke_handler(new);
cce4bc
     }
cce4bc
+    ap_die(access_status, new);
cce4bc
 }
cce4bc
 
cce4bc
 AP_DECLARE(void) ap_allow_methods(request_rec *r, int reset, ...)