From 7e51a871114c80c3ba40c5accc465c1c83e567ec Mon Sep 17 00:00:00 2001 From: Tatsuhiro Tsujikawa Date: Mon, 25 May 2015 23:59:44 +0900 Subject: [PATCH] nghttpx: Don't upgrade to HTTP/2 if we have non-final HTTP/1 response pending --- src/shrpx_https_upstream.cc | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/shrpx_https_upstream.cc b/src/shrpx_https_upstream.cc index c14973c2..e6748259 100644 --- a/src/shrpx_https_upstream.cc +++ b/src/shrpx_https_upstream.cc @@ -348,6 +348,11 @@ int htp_msg_completecb(http_parser *htp) { if (handler->get_http2_upgrade_allowed() && downstream->get_http2_upgrade_request() && + // we may write non-final header in response_buf, in this case, + // response_state is still INITIAL. So don't upgrade in this + // case, otherwise we end up send this non-final header as + // response body in HTTP/2 upstream. + downstream->get_response_buf()->rleft() == 0 && handler->perform_http2_upgrade(upstream) != 0) { if (LOG_ENABLED(INFO)) { ULOG(INFO, upstream) << "HTTP Upgrade to HTTP/2 failed";