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

shrpx: Refactor spdy downstream header field handling

parent c7071258
...@@ -195,7 +195,11 @@ int SpdyDownstreamConnection::push_request_headers() ...@@ -195,7 +195,11 @@ int SpdyDownstreamConnection::push_request_headers()
std::string via_value; std::string via_value;
std::string xff_value; std::string xff_value;
std::string scheme, path, query; std::string scheme, path, query;
if(downstream_->get_request_method() != "CONNECT") { if(downstream_->get_request_method() == "CONNECT") {
// No :scheme header field for CONNECT method.
nv[hdidx++] = ":path";
nv[hdidx++] = downstream_->get_request_path().c_str();
} else {
http_parser_url u; http_parser_url u;
const char *url = downstream_->get_request_path().c_str(); const char *url = downstream_->get_request_path().c_str();
memset(&u, 0, sizeof(u)); memset(&u, 0, sizeof(u));
...@@ -206,29 +210,33 @@ int SpdyDownstreamConnection::push_request_headers() ...@@ -206,29 +210,33 @@ int SpdyDownstreamConnection::push_request_headers()
copy_url_component(scheme, &u, UF_SCHEMA, url); copy_url_component(scheme, &u, UF_SCHEMA, url);
copy_url_component(path, &u, UF_PATH, url); copy_url_component(path, &u, UF_PATH, url);
copy_url_component(query, &u, UF_QUERY, url); copy_url_component(query, &u, UF_QUERY, url);
if(path.empty()) {
path = "/";
}
if(!query.empty()) { if(!query.empty()) {
path += "?"; path += "?";
path += query; path += query;
} }
} }
nv[hdidx++] = ":scheme";
if(scheme.empty()) {
// The default scheme is http. For SPDY upstream, the path must
// be absolute URI, so scheme should be provided.
nv[hdidx++] = "http";
} else {
nv[hdidx++] = scheme.c_str();
}
nv[hdidx++] = ":path";
if(path.empty()) {
nv[hdidx++] = downstream_->get_request_path().c_str();
} else {
nv[hdidx++] = path.c_str();
}
} }
nv[hdidx++] = ":method"; nv[hdidx++] = ":method";
nv[hdidx++] = downstream_->get_request_method().c_str(); nv[hdidx++] = downstream_->get_request_method().c_str();
nv[hdidx++] = ":scheme";
if(scheme.empty()) {
// Currently, the user of this downstream connecion is HTTP
// only.
nv[hdidx++] = "http";
} else {
nv[hdidx++] = scheme.c_str();
}
nv[hdidx++] = ":path";
if(downstream_->get_request_method() == "CONNECT" || path.empty()) {
nv[hdidx++] = downstream_->get_request_path().c_str();
} else {
nv[hdidx++] = path.c_str();
}
nv[hdidx++] = ":version"; nv[hdidx++] = ":version";
nv[hdidx++] = "HTTP/1.1"; nv[hdidx++] = "HTTP/1.1";
bool chunked_encoding = false; bool chunked_encoding = false;
......
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