]> git.ipfire.org Git - thirdparty/apache/httpd.git/commitdiff
Merge r1779574, r1779623 from trunk:
authorJim Jagielski <jim@apache.org>
Mon, 3 Apr 2017 11:29:02 +0000 (11:29 +0000)
committerJim Jagielski <jim@apache.org>
Mon, 3 Apr 2017 11:29:02 +0000 (11:29 +0000)
mod_proxy_hcheck: Don't validate timed out responses.

mod_proxy_hcheck: follow up to r1779574.
Parse/validate response bodies.

Submitted by: ylavic
Reviewed by: ylavic, jim, druggeri

git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/branches/2.4.x@1789960 13f79535-47bb-0310-9956-ffa450edef68

CHANGES
STATUS
modules/proxy/mod_proxy_hcheck.c

diff --git a/CHANGES b/CHANGES
index c2e7798b272e1cd61a25d5254d601e2a1a5e1bc1..072ff34b3d893f514f1c36e8562f14006209886b 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -29,6 +29,8 @@ Changes with Apache 2.4.26
      checks, loads and saves the request.
      PR 60577.  [Yann Ylavic]
   
+  *) mod_proxy_hcheck: Don't validate timed out responses.  [Yann Ylavic]
+
   *) mod_proxy_hcheck: Ensure thread-safety when concurrent healthchecks are
      in use (ProxyHCTPsize > 0).  PR 60071.  [Yann Ylavic, Jim Jagielski]
 
diff --git a/STATUS b/STATUS
index 6905b89cef6272bb58964f84bfff869c1b72a141..d1e72796ae9a05bfb16a888db969458e9658ac0f 100644 (file)
--- a/STATUS
+++ b/STATUS
@@ -118,12 +118,6 @@ RELEASE SHOWSTOPPERS:
 PATCHES ACCEPTED TO BACKPORT FROM TRUNK:
   [ start all new proposals below, under PATCHES PROPOSED. ]
 
-  *) mod_proxy_hcheck: Don't validate timed out responses.
-     trunk patch: http://svn.apache.org/r1779574
-                  http://svn.apache.org/r1779623
-     2.4.x patch: trunk works *after r1779573 above* (modulo CHANGES)
-     +1: ylavic, jim, druggeri
-
   *) mod_autoindex: Add IndexOptions UseOldDateFormat to allow the date
      format from 2.2 in the Last Modified column. PR60846.
      trunk patch: http://svn.apache.org/r1787525
index b916a92e267244ecb53bae80427334a8e867321a..39a4914c2d9810101b547338fe1a064928ced2de 100644 (file)
@@ -344,17 +344,19 @@ static request_rec *create_request_rec(apr_pool_t *p, conn_rec *conn, const char
     r->connection->bucket_alloc = ba;
     r->server          = conn->base_server;
 
+    r->proxyreq        = PROXYREQ_RESPONSE;
+
     r->user            = NULL;
     r->ap_auth_type    = NULL;
 
     r->allowed_methods = ap_make_method_list(p, 2);
 
-    r->headers_in      = apr_table_make(r->pool, 25);
-    r->trailers_in     = apr_table_make(r->pool, 5);
+    r->headers_in      = apr_table_make(r->pool, 1);
+    r->trailers_in     = apr_table_make(r->pool, 1);
     r->subprocess_env  = apr_table_make(r->pool, 25);
     r->headers_out     = apr_table_make(r->pool, 12);
     r->err_headers_out = apr_table_make(r->pool, 5);
-    r->trailers_out    = apr_table_make(r->pool, 5);
+    r->trailers_out    = apr_table_make(r->pool, 1);
     r->notes           = apr_table_make(r->pool, 5);
 
     r->kept_body       = apr_brigade_create(r->pool, r->connection->bucket_alloc);
@@ -373,7 +375,6 @@ static request_rec *create_request_rec(apr_pool_t *p, conn_rec *conn, const char
     r->read_body       = REQUEST_NO_BODY;
 
     r->status          = HTTP_OK;  /* Until further notice */
-    r->header_only     = 1;
     r->the_request     = NULL;
 
     /* Begin by presuming any module can make its own path_info assumptions,
@@ -389,7 +390,11 @@ static request_rec *create_request_rec(apr_pool_t *p, conn_rec *conn, const char
     r->method = method;
     /* Provide quick information about the request method as soon as known */
     r->method_number = ap_method_number_of(r->method);
-    if (r->method_number == M_GET && r->method[0] == 'G') {
+    if (r->method_number == M_OPTIONS
+            || (r->method_number == M_GET && r->method[0] == 'H')) {
+        r->header_only = 1;
+    }
+    else {
         r->header_only = 0;
     }
 
@@ -690,7 +695,7 @@ static int hc_read_body(request_rec *r, apr_bucket_brigade *bb)
                             APR_BLOCK_READ, len);
 
         if (rv != APR_SUCCESS) {
-            if (APR_STATUS_IS_TIMEUP(rv) || APR_STATUS_IS_EOF(rv)) {
+            if (APR_STATUS_IS_EOF(rv)) {
                 rv = APR_SUCCESS;
                 break;
             }
@@ -764,10 +769,16 @@ static apr_status_t hc_check_http(baton_t *baton)
     if ((status = hc_read_headers(r)) != OK) {
         return backend_cleanup("HCOH", backend, ctx->s, status);
     }
-    if (hc->s->method == GET) {
-        if ((status = hc_read_body(r, bb)) != OK) {
+    if (!r->header_only) {
+        apr_table_t *saved_headers_in = r->headers_in;
+        r->headers_in = apr_table_copy(r->pool, r->headers_out);
+        ap_proxy_pre_http_request(backend->connection, r);
+        status = hc_read_body(r, bb);
+        r->headers_in = saved_headers_in;
+        if (status != OK) {
             return backend_cleanup("HCOH", backend, ctx->s, status);
         }
+        r->trailers_out = apr_table_copy(r->pool, r->trailers_in);
     }
 
     if (*worker->s->hcexpr &&