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);