From 42c1370b28735479c066886eceb556c6129eb5d0 Mon Sep 17 00:00:00 2001 From: Stefan Eissing Date: Mon, 23 Jan 2017 20:10:20 +0000 Subject: [PATCH] On the trunk: *) 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 | 3 +++ modules/http2/h2_from_h1.c | 23 ++++++++++++++--------- 2 files changed, 17 insertions(+), 9 deletions(-) diff --git a/CHANGES b/CHANGES index f192b9cb28..015389547b 100644 --- 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 diff --git a/modules/http2/h2_from_h1.c b/modules/http2/h2_from_h1.c index fbcf483ef3..d3f07a1b00 100644 --- a/modules/http2/h2_from_h1.c +++ b/modules/http2/h2_from_h1.c @@ -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; } -- 2.40.0