nghttpx: Reworkd inherited request headers in PUSH_PROMISE
This commit is contained in:
parent
b14cfaf308
commit
88f0bc70c4
|
@ -21,9 +21,11 @@ HEADERS = [
|
|||
"content-length",
|
||||
"location",
|
||||
"trailer",
|
||||
"referer",
|
||||
"link",
|
||||
"accept",
|
||||
"accept-encoding",
|
||||
"accept-language",
|
||||
"cache-control",
|
||||
"user-agent",
|
||||
# disallowed h1 headers
|
||||
'connection',
|
||||
'keep-alive',
|
||||
|
|
30
src/http2.cc
30
src/http2.cc
|
@ -478,9 +478,6 @@ int lookup_token(const uint8_t *name, size_t namelen) {
|
|||
}
|
||||
break;
|
||||
case 't':
|
||||
if (util::streq("accep", name, 5)) {
|
||||
return HD_ACCEPT;
|
||||
}
|
||||
if (util::streq("expec", name, 5)) {
|
||||
return HD_EXPECT;
|
||||
}
|
||||
|
@ -508,9 +505,6 @@ int lookup_token(const uint8_t *name, size_t namelen) {
|
|||
}
|
||||
break;
|
||||
case 'r':
|
||||
if (util::streq("refere", name, 6)) {
|
||||
return HD_REFERER;
|
||||
}
|
||||
if (util::streq("traile", name, 6)) {
|
||||
return HD_TRAILER;
|
||||
}
|
||||
|
@ -543,6 +537,11 @@ int lookup_token(const uint8_t *name, size_t namelen) {
|
|||
return HD_CONNECTION;
|
||||
}
|
||||
break;
|
||||
case 't':
|
||||
if (util::streq("user-agen", name, 9)) {
|
||||
return HD_USER_AGENT;
|
||||
}
|
||||
break;
|
||||
case 'y':
|
||||
if (util::streq(":authorit", name, 9)) {
|
||||
return HD__AUTHORITY;
|
||||
|
@ -550,6 +549,15 @@ int lookup_token(const uint8_t *name, size_t namelen) {
|
|||
break;
|
||||
}
|
||||
break;
|
||||
case 13:
|
||||
switch (name[namelen - 1]) {
|
||||
case 'l':
|
||||
if (util::streq("cache-contro", name, 12)) {
|
||||
return HD_CACHE_CONTROL;
|
||||
}
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case 14:
|
||||
switch (name[namelen - 1]) {
|
||||
case 'h':
|
||||
|
@ -566,6 +574,16 @@ int lookup_token(const uint8_t *name, size_t namelen) {
|
|||
break;
|
||||
case 15:
|
||||
switch (name[namelen - 1]) {
|
||||
case 'e':
|
||||
if (util::streq("accept-languag", name, 14)) {
|
||||
return HD_ACCEPT_LANGUAGE;
|
||||
}
|
||||
break;
|
||||
case 'g':
|
||||
if (util::streq("accept-encodin", name, 14)) {
|
||||
return HD_ACCEPT_ENCODING;
|
||||
}
|
||||
break;
|
||||
case 'r':
|
||||
if (util::streq("x-forwarded-fo", name, 14)) {
|
||||
return HD_X_FORWARDED_FOR;
|
||||
|
|
|
@ -195,8 +195,10 @@ enum {
|
|||
HD__PATH,
|
||||
HD__SCHEME,
|
||||
HD__STATUS,
|
||||
HD_ACCEPT,
|
||||
HD_ACCEPT_ENCODING,
|
||||
HD_ACCEPT_LANGUAGE,
|
||||
HD_ALT_SVC,
|
||||
HD_CACHE_CONTROL,
|
||||
HD_CONNECTION,
|
||||
HD_CONTENT_LENGTH,
|
||||
HD_COOKIE,
|
||||
|
@ -208,12 +210,12 @@ enum {
|
|||
HD_LINK,
|
||||
HD_LOCATION,
|
||||
HD_PROXY_CONNECTION,
|
||||
HD_REFERER,
|
||||
HD_SERVER,
|
||||
HD_TE,
|
||||
HD_TRAILER,
|
||||
HD_TRANSFER_ENCODING,
|
||||
HD_UPGRADE,
|
||||
HD_USER_AGENT,
|
||||
HD_VIA,
|
||||
HD_X_FORWARDED_FOR,
|
||||
HD_X_FORWARDED_PROTO,
|
||||
|
|
|
@ -568,6 +568,9 @@ int on_frame_send_callback(nghttp2_session *session, const nghttp2_frame *frame,
|
|||
downstream->set_request_path({nv.value, nv.value + nv.valuelen});
|
||||
break;
|
||||
}
|
||||
downstream->add_request_header(nv.name, nv.namelen, nv.value, nv.valuelen,
|
||||
nv.flags & NGHTTP2_NV_FLAG_NO_INDEX,
|
||||
token);
|
||||
}
|
||||
|
||||
downstream->inspect_http2_request();
|
||||
|
@ -1588,6 +1591,16 @@ int Http2Upstream::submit_push_promise(const std::string &path,
|
|||
nva.reserve(downstream->get_request_headers().size());
|
||||
for (auto &kv : downstream->get_request_headers()) {
|
||||
switch (kv.token) {
|
||||
// TODO generate referer
|
||||
case http2::HD__AUTHORITY:
|
||||
case http2::HD__SCHEME:
|
||||
case http2::HD_ACCEPT_ENCODING:
|
||||
case http2::HD_ACCEPT_LANGUAGE:
|
||||
case http2::HD_CACHE_CONTROL:
|
||||
case http2::HD_HOST:
|
||||
case http2::HD_USER_AGENT:
|
||||
nva.push_back(http2::make_nv(kv.name, kv.value, kv.no_index));
|
||||
break;
|
||||
case http2::HD__METHOD:
|
||||
// juse use "GET" for now
|
||||
nva.push_back(http2::make_nv_lc(":method", "GET"));
|
||||
|
@ -1595,15 +1608,7 @@ int Http2Upstream::submit_push_promise(const std::string &path,
|
|||
case http2::HD__PATH:
|
||||
nva.push_back(http2::make_nv_ls(":path", path));
|
||||
continue;
|
||||
case http2::HD_ACCEPT:
|
||||
// browser tends to change accept header field value depending
|
||||
// on requesting resource. So just omit it for now.
|
||||
continue;
|
||||
case http2::HD_REFERER:
|
||||
// TODO construct referer
|
||||
continue;
|
||||
}
|
||||
nva.push_back(http2::make_nv(kv.name, kv.value, kv.no_index));
|
||||
}
|
||||
|
||||
rv = nghttp2_submit_push_promise(session_, NGHTTP2_FLAG_NONE,
|
||||
|
|
Loading…
Reference in New Issue