From 2f50bc1b3ce4c938f517bea8d0f465e6b9d3543c Mon Sep 17 00:00:00 2001 From: Tatsuhiro Tsujikawa Date: Tue, 5 Jan 2016 16:47:44 +0900 Subject: [PATCH] nghttpx: Take into account of trailers when applying max_header_fields --- src/shrpx_http2_upstream.cc | 3 ++- src/shrpx_https_upstream.cc | 3 ++- src/shrpx_spdy_upstream.cc | 2 ++ 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/shrpx_http2_upstream.cc b/src/shrpx_http2_upstream.cc index bc0de69c..de1dec18 100644 --- a/src/shrpx_http2_upstream.cc +++ b/src/shrpx_http2_upstream.cc @@ -169,7 +169,8 @@ int on_header_callback(nghttp2_session *session, const nghttp2_frame *frame, if (downstream->get_request_headers_sum() + namelen + valuelen > get_config()->header_field_buffer || - downstream->get_request_headers().size() >= + downstream->get_request_headers().size() + + downstream->get_request_trailers().size() >= get_config()->max_header_fields) { if (downstream->get_response_state() == Downstream::MSG_COMPLETE) { return 0; diff --git a/src/shrpx_https_upstream.cc b/src/shrpx_https_upstream.cc index 1acd8f4a..8f584749 100644 --- a/src/shrpx_https_upstream.cc +++ b/src/shrpx_https_upstream.cc @@ -146,7 +146,8 @@ int htp_hdr_keycb(http_parser *htp, const char *data, size_t len) { if (downstream->get_request_trailer_key_prev()) { downstream->append_last_request_trailer_key(data, len); } else { - if (downstream->get_request_headers().size() >= + if (downstream->get_request_headers().size() + + downstream->get_request_trailers().size() >= get_config()->max_header_fields) { if (LOG_ENABLED(INFO)) { ULOG(INFO, upstream) << "Too many header field num=" diff --git a/src/shrpx_spdy_upstream.cc b/src/shrpx_spdy_upstream.cc index d7d2269a..604fb612 100644 --- a/src/shrpx_spdy_upstream.cc +++ b/src/shrpx_spdy_upstream.cc @@ -169,6 +169,8 @@ void on_ctrl_recv_callback(spdylay_session *session, spdylay_frame_type type, header_buffer += strlen(nv[i]) + strlen(nv[i + 1]); } + // spdy does not define usage of trailer fields, and we ignores + // them. if (header_buffer > get_config()->header_field_buffer || num_headers > get_config()->max_header_fields) { upstream->rst_stream(downstream, SPDYLAY_INTERNAL_ERROR);