Commit 9afebcb2 authored by Tatsuhiro Tsujikawa's avatar Tatsuhiro Tsujikawa

nghttpx: Ignore port when rewriting location header

parent ccfa13cd
...@@ -457,27 +457,15 @@ std::string rewrite_location_uri(const std::string& uri, ...@@ -457,27 +457,15 @@ std::string rewrite_location_uri(const std::string& uri,
if((u.field_set & (1 << UF_HOST)) == 0) { if((u.field_set & (1 << UF_HOST)) == 0) {
return ""; return "";
} }
std::string host; auto field = &u.field_data[UF_HOST];
copy_url_component(host, &u, UF_HOST, uri.c_str()); if(!util::startsWith(std::begin(request_host), std::end(request_host),
if(u.field_set & (1 << UF_PORT)) { &uri[field->off], &uri[field->off] + field->len) ||
host += ":"; (request_host.size() != field->len &&
host += util::utos(u.port); request_host[field->len] != ':')) {
if(host != request_host) {
// :authority or host have "host", but host in location header
// field may have "host:port".
auto field = &u.field_data[UF_HOST];
if(!util::streq(request_host.c_str(), request_host.size(),
&uri[field->off], field->len) ||
downstream_port != u.port) {
return "";
}
}
} else if(host != request_host) {
return ""; return "";
} }
std::string res = upstream_scheme; std::string res = upstream_scheme;
res += "://"; res += "://";
auto field = &u.field_data[UF_HOST];
res.append(&uri[field->off], field->len); res.append(&uri[field->off], field->len);
if(upstream_scheme == "http") { if(upstream_scheme == "http") {
if(upstream_port != 80) { if(upstream_port != 80) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment