From 8aab74ad36f989128a6ee2f5577566863e582d48 Mon Sep 17 00:00:00 2001 From: Tatsuhiro Tsujikawa Date: Tue, 16 Jun 2015 21:31:33 +0900 Subject: [PATCH] nghttpx: Refactor a bit --- src/shrpx_http_downstream_connection.cc | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/shrpx_http_downstream_connection.cc b/src/shrpx_http_downstream_connection.cc index bb50a646..500286eb 100644 --- a/src/shrpx_http_downstream_connection.cc +++ b/src/shrpx_http_downstream_connection.cc @@ -251,6 +251,9 @@ int HttpDownstreamConnection::push_request_headers() { // Assume that method and request path do not contain \r\n. std::string hdrs = http2::to_method_string(downstream_->get_request_method()); hdrs += ' '; + + auto &scheme = downstream_->get_request_http2_scheme(); + if (connect_method) { if (authority) { hdrs += authority; @@ -260,8 +263,8 @@ int HttpDownstreamConnection::push_request_headers() { } else if (get_config()->http2_proxy || get_config()->client_proxy) { // Construct absolute-form request target because we are going to // send a request to a HTTP/1 proxy. - assert(!downstream_->get_request_http2_scheme().empty()); - hdrs += downstream_->get_request_http2_scheme(); + assert(!scheme.empty()); + hdrs += scheme; hdrs += "://"; if (authority) { @@ -344,8 +347,8 @@ int HttpDownstreamConnection::push_request_headers() { if (!get_config()->http2_proxy && !get_config()->client_proxy && !connect_method) { hdrs += "X-Forwarded-Proto: "; - assert(!downstream_->get_request_http2_scheme().empty()); - hdrs += downstream_->get_request_http2_scheme(); + assert(!scheme.empty()); + hdrs += scheme; hdrs += "\r\n"; } auto via = downstream_->get_request_header(http2::HD_VIA);