nghttpx: Don't rewrite path if http2 proxy or client proxy is enabled
There are many requests which changes its meaning when we rewrite path. This is due to bad percent-encoding in URI; reserved characters are just used without percent encoding. It seems this is common in ad services, but I suspect more to come. For reverse proxying situation, sane service most likely encodes URI properly, so probably this is not an issue.
This commit is contained in:
parent
1a63cd94aa
commit
fa7069a273
|
@ -301,10 +301,14 @@ int Http2Upstream::on_request_headers(Downstream *downstream,
|
||||||
downstream->set_request_http2_scheme(http2::value_to_str(scheme));
|
downstream->set_request_http2_scheme(http2::value_to_str(scheme));
|
||||||
downstream->set_request_http2_authority(http2::value_to_str(authority));
|
downstream->set_request_http2_authority(http2::value_to_str(authority));
|
||||||
if (path) {
|
if (path) {
|
||||||
|
if (get_config()->http2_proxy || get_config()->client_proxy) {
|
||||||
|
downstream->set_request_path(http2::value_to_str(path));
|
||||||
|
} else {
|
||||||
auto &value = path->value;
|
auto &value = path->value;
|
||||||
downstream->set_request_path(
|
downstream->set_request_path(
|
||||||
http2::rewrite_clean_path(std::begin(value), std::end(value)));
|
http2::rewrite_clean_path(std::begin(value), std::end(value)));
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (!(frame->hd.flags & NGHTTP2_FLAG_END_STREAM)) {
|
if (!(frame->hd.flags & NGHTTP2_FLAG_END_STREAM)) {
|
||||||
downstream->set_request_http2_expect_body(true);
|
downstream->set_request_http2_expect_body(true);
|
||||||
|
|
|
@ -218,8 +218,12 @@ void rewrite_request_host_path_from_uri(Downstream *downstream, const char *uri,
|
||||||
path += '?';
|
path += '?';
|
||||||
path.append(uri + fdata.off, fdata.len);
|
path.append(uri + fdata.off, fdata.len);
|
||||||
}
|
}
|
||||||
|
if (get_config()->http2_proxy || get_config()->client_proxy) {
|
||||||
|
downstream->set_request_path(std::move(path));
|
||||||
|
} else {
|
||||||
downstream->set_request_path(
|
downstream->set_request_path(
|
||||||
http2::rewrite_clean_path(std::begin(path), std::end(path)));
|
http2::rewrite_clean_path(std::begin(path), std::end(path)));
|
||||||
|
}
|
||||||
|
|
||||||
std::string scheme;
|
std::string scheme;
|
||||||
http2::copy_url_component(scheme, &u, UF_SCHEMA, uri);
|
http2::copy_url_component(scheme, &u, UF_SCHEMA, uri);
|
||||||
|
|
|
@ -229,9 +229,13 @@ void on_ctrl_recv_callback(spdylay_session *session, spdylay_frame_type type,
|
||||||
} else {
|
} else {
|
||||||
downstream->set_request_http2_scheme(scheme->value);
|
downstream->set_request_http2_scheme(scheme->value);
|
||||||
downstream->set_request_http2_authority(host->value);
|
downstream->set_request_http2_authority(host->value);
|
||||||
|
if (get_config()->http2_proxy || get_config()->client_proxy) {
|
||||||
|
downstream->set_request_path(path->value);
|
||||||
|
} else {
|
||||||
downstream->set_request_path(http2::rewrite_clean_path(
|
downstream->set_request_path(http2::rewrite_clean_path(
|
||||||
std::begin(path->value), std::end(path->value)));
|
std::begin(path->value), std::end(path->value)));
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (!(frame->syn_stream.hd.flags & SPDYLAY_CTRL_FLAG_FIN)) {
|
if (!(frame->syn_stream.hd.flags & SPDYLAY_CTRL_FLAG_FIN)) {
|
||||||
downstream->set_request_http2_expect_body(true);
|
downstream->set_request_http2_expect_body(true);
|
||||||
|
|
Loading…
Reference in New Issue