nghttpx: Add x-http2-push header field for pushed resource
Fixes GH-352
This commit is contained in:
parent
1148584526
commit
d22573086f
|
@ -1321,8 +1321,9 @@ int Http2Upstream::on_downstream_header_complete(Downstream *downstream) {
|
||||||
|
|
||||||
size_t nheader = downstream->get_response_headers().size();
|
size_t nheader = downstream->get_response_headers().size();
|
||||||
auto nva = std::vector<nghttp2_nv>();
|
auto nva = std::vector<nghttp2_nv>();
|
||||||
// 3 means :status and possible server and via header field.
|
// 4 means :status and possible server, via and x-http2-push header
|
||||||
nva.reserve(nheader + 3 + get_config()->add_response_headers.size());
|
// field.
|
||||||
|
nva.reserve(nheader + 4 + get_config()->add_response_headers.size());
|
||||||
std::string via_value;
|
std::string via_value;
|
||||||
auto response_status = util::utos(downstream->get_response_http_status());
|
auto response_status = util::utos(downstream->get_response_http_status());
|
||||||
nva.push_back(http2::make_nv_ls(":status", response_status));
|
nva.push_back(http2::make_nv_ls(":status", response_status));
|
||||||
|
@ -1376,6 +1377,12 @@ int Http2Upstream::on_downstream_header_complete(Downstream *downstream) {
|
||||||
nva.push_back(http2::make_nv(p.first, p.second));
|
nva.push_back(http2::make_nv(p.first, p.second));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (downstream->get_stream_id() % 2 == 0) {
|
||||||
|
// This header field is basically for human on client side to
|
||||||
|
// figure out that the resource is pushed.
|
||||||
|
nva.push_back(http2::make_nv_ll("x-http2-push", "1"));
|
||||||
|
}
|
||||||
|
|
||||||
if (LOG_ENABLED(INFO)) {
|
if (LOG_ENABLED(INFO)) {
|
||||||
log_response_headers(downstream, nva);
|
log_response_headers(downstream, nva);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue