]> granicus.if.org Git - apache/commitdiff
On the trunk:
authorStefan Eissing <icing@apache.org>
Mon, 23 Jan 2017 20:10:20 +0000 (20:10 +0000)
committerStefan Eissing <icing@apache.org>
Mon, 23 Jan 2017 20:10:20 +0000 (20:10 +0000)
  *) mod_http2: fixes PR60599, sending proper response for conditional requests
     answered by mod_cache. [Jeff Wheelhouse, Stefan Eissing]

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

CHANGES
modules/http2/h2_from_h1.c

diff --git a/CHANGES b/CHANGES
index f192b9cb28d7bc8358dffae34e90259f9ef8fb2f..015389547b20ca53b879173d2092ca916a4edd18 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -1,6 +1,9 @@
                                                          -*- coding: utf-8 -*-
 Changes with Apache 2.5.0
 
+  *) mod_http2: fixes PR60599, sending proper response for conditional requests
+     answered by mod_cache. [Jeff Wheelhouse, Stefan Eissing]
+     
   *) mod_proxy_hcheck: Don't validate timed out responses.  [Yann Ylavic]
 
   *) mod_proxy_hcheck: Ensure thread-safety when concurrent healthchecks are
index fbcf483ef3b7e5139791ea8660cd12d25ba38a2b..d3f07a1b00d39dc41b8660bcdcae10963d73873a 100644 (file)
@@ -513,7 +513,7 @@ apr_status_t h2_filter_headers_out(ap_filter_t *f, apr_bucket_brigade *bb)
     apr_bucket *b, *bresp, *body_bucket = NULL, *next;
     ap_bucket_error *eb = NULL;
     h2_headers *response = NULL;
-
+    int headers_passing = 0;
     ap_log_cerror(APLOG_MARK, APLOG_TRACE1, 0, f->c,
                   "h2_task(%s): output_filter called", task->id);
     
@@ -527,10 +527,6 @@ apr_status_t h2_filter_headers_out(ap_filter_t *f, apr_bucket_brigade *bb)
             if (AP_BUCKET_IS_ERROR(b) && !eb) {
                 eb = b->data;
             }
-            else if (APR_BUCKET_IS_EOS(b) || AP_BUCKET_IS_EOR(b)) {
-                body_bucket = b;
-                break;
-            } 
             else if (AP_BUCKET_IS_EOC(b)) {
                 /* If we see an EOC bucket it is a signal that we should get out
                  * of the way doing nothing.
@@ -540,7 +536,10 @@ apr_status_t h2_filter_headers_out(ap_filter_t *f, apr_bucket_brigade *bb)
                               "h2_task(%s): eoc bucket passed", task->id);
                 return ap_pass_brigade(f->next, bb);
             }
-            else if (!H2_BUCKET_IS_HEADERS(b) && !APR_BUCKET_IS_FLUSH(b)) { 
+            else if (H2_BUCKET_IS_HEADERS(b)) {
+                headers_passing = 1;
+            }
+            else if (!APR_BUCKET_IS_FLUSH(b)) { 
                 body_bucket = b;
                 break;
             }
@@ -557,8 +556,9 @@ apr_status_t h2_filter_headers_out(ap_filter_t *f, apr_bucket_brigade *bb)
             return AP_FILTER_ERROR;
         }
         
-        if (body_bucket) {
-            /* time to insert the response bucket before the body */
+        if (body_bucket || !headers_passing) {
+            /* time to insert the response bucket before the body or if
+             * no h2_headers is passed, e.g. the response is empty */
             response = create_response(task, r);
             if (response == NULL) {
                 ap_log_cerror(APLOG_MARK, APLOG_NOTICE, 0, f->c, APLOGNO(03048)
@@ -567,7 +567,12 @@ apr_status_t h2_filter_headers_out(ap_filter_t *f, apr_bucket_brigade *bb)
             }
             
             bresp = h2_bucket_headers_create(f->c->bucket_alloc, response);
-            APR_BUCKET_INSERT_BEFORE(body_bucket, bresp);
+            if (body_bucket) {
+                APR_BUCKET_INSERT_BEFORE(body_bucket, bresp);
+            }
+            else {
+                APR_BRIGADE_INSERT_HEAD(bb, bresp);
+            }
             task->output.sent_response = 1;
             r->sent_bodyct = 1;
         }