Skip to content

Commit

Permalink
nghttpx: Add x-http2-push header field for pushed resource
Browse files Browse the repository at this point in the history
  • Loading branch information
tatsuhiro-t committed Sep 13, 2015
1 parent 1148584 commit d225730
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/shrpx_http2_upstream.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1321,8 +1321,9 @@ int Http2Upstream::on_downstream_header_complete(Downstream *downstream) {

size_t nheader = downstream->get_response_headers().size();
auto nva = std::vector<nghttp2_nv>();
// 3 means :status and possible server and via header field.
nva.reserve(nheader + 3 + get_config()->add_response_headers.size());
// 4 means :status and possible server, via and x-http2-push header
// field.
nva.reserve(nheader + 4 + get_config()->add_response_headers.size());
std::string via_value;
auto response_status = util::utos(downstream->get_response_http_status());
nva.push_back(http2::make_nv_ls(":status", response_status));
Expand Down Expand Up @@ -1376,6 +1377,12 @@ int Http2Upstream::on_downstream_header_complete(Downstream *downstream) {
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)) {
log_response_headers(downstream, nva);
}
Expand Down

0 comments on commit d225730

Please sign in to comment.