You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@httpd.apache.org by ic...@apache.org on 2017/01/23 20:10:20 UTC

svn commit: r1779972 - in /httpd/httpd/trunk: CHANGES modules/http2/h2_from_h1.c

Author: icing
Date: Mon Jan 23 20:10:20 2017
New Revision: 1779972

URL: http://svn.apache.org/viewvc?rev=1779972&view=rev
Log:
On the trunk:

  *) mod_http2: fixes PR60599, sending proper response for conditional requests
     answered by mod_cache. [Jeff Wheelhouse, Stefan Eissing]


Modified:
    httpd/httpd/trunk/CHANGES
    httpd/httpd/trunk/modules/http2/h2_from_h1.c

Modified: httpd/httpd/trunk/CHANGES
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/CHANGES?rev=1779972&r1=1779971&r2=1779972&view=diff
==============================================================================
--- httpd/httpd/trunk/CHANGES [utf-8] (original)
+++ httpd/httpd/trunk/CHANGES [utf-8] Mon Jan 23 20:10:20 2017
@@ -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

Modified: httpd/httpd/trunk/modules/http2/h2_from_h1.c
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/modules/http2/h2_from_h1.c?rev=1779972&r1=1779971&r2=1779972&view=diff
==============================================================================
--- httpd/httpd/trunk/modules/http2/h2_from_h1.c (original)
+++ httpd/httpd/trunk/modules/http2/h2_from_h1.c Mon Jan 23 20:10:20 2017
@@ -513,7 +513,7 @@ apr_status_t h2_filter_headers_out(ap_fi
     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_fi
             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_fi
                               "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_fi
             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_fi
             }
             
             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;
         }