nghttpx: Take into account of trailers when applying max_header_fields

This commit is contained in:
Tatsuhiro Tsujikawa 2016-01-05 16:47:44 +09:00
parent 848f8fbe54
commit 2f50bc1b3c
3 changed files with 6 additions and 2 deletions

View File

@ -169,7 +169,8 @@ int on_header_callback(nghttp2_session *session, const nghttp2_frame *frame,
if (downstream->get_request_headers_sum() + namelen + valuelen > if (downstream->get_request_headers_sum() + namelen + valuelen >
get_config()->header_field_buffer || 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) { get_config()->max_header_fields) {
if (downstream->get_response_state() == Downstream::MSG_COMPLETE) { if (downstream->get_response_state() == Downstream::MSG_COMPLETE) {
return 0; return 0;

View File

@ -146,7 +146,8 @@ int htp_hdr_keycb(http_parser *htp, const char *data, size_t len) {
if (downstream->get_request_trailer_key_prev()) { if (downstream->get_request_trailer_key_prev()) {
downstream->append_last_request_trailer_key(data, len); downstream->append_last_request_trailer_key(data, len);
} else { } else {
if (downstream->get_request_headers().size() >= if (downstream->get_request_headers().size() +
downstream->get_request_trailers().size() >=
get_config()->max_header_fields) { get_config()->max_header_fields) {
if (LOG_ENABLED(INFO)) { if (LOG_ENABLED(INFO)) {
ULOG(INFO, upstream) << "Too many header field num=" ULOG(INFO, upstream) << "Too many header field num="

View File

@ -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]); 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 || if (header_buffer > get_config()->header_field_buffer ||
num_headers > get_config()->max_header_fields) { num_headers > get_config()->max_header_fields) {
upstream->rst_stream(downstream, SPDYLAY_INTERNAL_ERROR); upstream->rst_stream(downstream, SPDYLAY_INTERNAL_ERROR);