shrpx: Refactor spdy downstream header field handling
This commit is contained in:
parent
c707125839
commit
9b4245368a
|
@ -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()
|
||||||
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++] = ":method";
|
|
||||||
nv[hdidx++] = downstream_->get_request_method().c_str();
|
|
||||||
nv[hdidx++] = ":scheme";
|
nv[hdidx++] = ":scheme";
|
||||||
if(scheme.empty()) {
|
if(scheme.empty()) {
|
||||||
// Currently, the user of this downstream connecion is HTTP
|
// The default scheme is http. For SPDY upstream, the path must
|
||||||
// only.
|
// be absolute URI, so scheme should be provided.
|
||||||
nv[hdidx++] = "http";
|
nv[hdidx++] = "http";
|
||||||
} else {
|
} else {
|
||||||
nv[hdidx++] = scheme.c_str();
|
nv[hdidx++] = scheme.c_str();
|
||||||
}
|
}
|
||||||
nv[hdidx++] = ":path";
|
nv[hdidx++] = ":path";
|
||||||
if(downstream_->get_request_method() == "CONNECT" || path.empty()) {
|
if(path.empty()) {
|
||||||
nv[hdidx++] = downstream_->get_request_path().c_str();
|
nv[hdidx++] = downstream_->get_request_path().c_str();
|
||||||
} else {
|
} else {
|
||||||
nv[hdidx++] = path.c_str();
|
nv[hdidx++] = path.c_str();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
nv[hdidx++] = ":method";
|
||||||
|
nv[hdidx++] = downstream_->get_request_method().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;
|
||||||
|
|
Loading…
Reference in New Issue