nghttpx: Refactor a bit
This commit is contained in:
parent
46e3be7b5b
commit
de0543f684
|
@ -261,15 +261,16 @@ int Http2DownstreamConnection::push_request_headers() {
|
||||||
// http2session_ has already in CONNECTED state, so we can get
|
// http2session_ has already in CONNECTED state, so we can get
|
||||||
// addr_idx here.
|
// addr_idx here.
|
||||||
auto addr_idx = http2session_->get_addr_idx();
|
auto addr_idx = http2session_->get_addr_idx();
|
||||||
auto &downstream_addr = get_config()->downstream_addrs[addr_idx];
|
auto downstream_hostport =
|
||||||
|
get_config()->downstream_addrs[addr_idx].hostport.get();
|
||||||
|
|
||||||
const char *authority = nullptr, *host = nullptr;
|
const char *authority = nullptr, *host = nullptr;
|
||||||
if (!no_host_rewrite) {
|
if (!no_host_rewrite) {
|
||||||
if (!downstream_->get_request_http2_authority().empty()) {
|
if (!downstream_->get_request_http2_authority().empty()) {
|
||||||
authority = downstream_addr.hostport.get();
|
authority = downstream_hostport;
|
||||||
}
|
}
|
||||||
if (downstream_->get_request_header(http2::HD_HOST)) {
|
if (downstream_->get_request_header(http2::HD_HOST)) {
|
||||||
host = downstream_addr.hostport.get();
|
host = downstream_hostport;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (!downstream_->get_request_http2_authority().empty()) {
|
if (!downstream_->get_request_http2_authority().empty()) {
|
||||||
|
@ -284,7 +285,7 @@ int Http2DownstreamConnection::push_request_headers() {
|
||||||
if (!authority && !host) {
|
if (!authority && !host) {
|
||||||
// upstream is HTTP/1.0. We use backend server's host
|
// upstream is HTTP/1.0. We use backend server's host
|
||||||
// nonetheless.
|
// nonetheless.
|
||||||
host = downstream_addr.hostport.get();
|
host = downstream_hostport;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (authority) {
|
if (authority) {
|
||||||
|
|
|
@ -211,14 +211,17 @@ int HttpDownstreamConnection::attach_downstream(Downstream *downstream) {
|
||||||
|
|
||||||
int HttpDownstreamConnection::push_request_headers() {
|
int HttpDownstreamConnection::push_request_headers() {
|
||||||
const char *authority = nullptr, *host = nullptr;
|
const char *authority = nullptr, *host = nullptr;
|
||||||
|
auto downstream_hostport =
|
||||||
|
get_config()->downstream_addrs[addr_idx_].hostport.get();
|
||||||
|
|
||||||
if (!get_config()->no_host_rewrite && !get_config()->http2_proxy &&
|
if (!get_config()->no_host_rewrite && !get_config()->http2_proxy &&
|
||||||
!get_config()->client_proxy &&
|
!get_config()->client_proxy &&
|
||||||
downstream_->get_request_method() != "CONNECT") {
|
downstream_->get_request_method() != "CONNECT") {
|
||||||
if (!downstream_->get_request_http2_authority().empty()) {
|
if (!downstream_->get_request_http2_authority().empty()) {
|
||||||
authority = get_config()->downstream_addrs[addr_idx_].hostport.get();
|
authority = downstream_hostport;
|
||||||
}
|
}
|
||||||
if (downstream_->get_request_header(http2::HD_HOST)) {
|
if (downstream_->get_request_header(http2::HD_HOST)) {
|
||||||
host = get_config()->downstream_addrs[addr_idx_].hostport.get();
|
host = downstream_hostport;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (!downstream_->get_request_http2_authority().empty()) {
|
if (!downstream_->get_request_http2_authority().empty()) {
|
||||||
|
@ -233,7 +236,7 @@ int HttpDownstreamConnection::push_request_headers() {
|
||||||
if (!authority && !host) {
|
if (!authority && !host) {
|
||||||
// upstream is HTTP/1.0. We use backend server's host
|
// upstream is HTTP/1.0. We use backend server's host
|
||||||
// nonetheless.
|
// nonetheless.
|
||||||
host = get_config()->downstream_addrs[addr_idx_].hostport.get();
|
host = downstream_hostport;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (authority) {
|
if (authority) {
|
||||||
|
|
Loading…
Reference in New Issue