Skip to content

Commit

Permalink
Add nghttp2_option_set_max_continuations
Browse files Browse the repository at this point in the history
  • Loading branch information
tatsuhiro-t committed Apr 4, 2024
1 parent 00201ec commit d71a466
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 0 deletions.
1 change: 1 addition & 0 deletions doc/Makefile.am
Expand Up @@ -77,6 +77,7 @@ APIDOCS= \
nghttp2_option_set_peer_max_concurrent_streams.rst \
nghttp2_option_set_server_fallback_rfc7540_priorities.rst \
nghttp2_option_set_user_recv_extension_type.rst \
nghttp2_option_set_max_continuations.rst \
nghttp2_option_set_max_outbound_ack.rst \
nghttp2_option_set_max_settings.rst \
nghttp2_option_set_stream_reset_rate_limit.rst \
Expand Down
11 changes: 11 additions & 0 deletions lib/includes/nghttp2/nghttp2.h
Expand Up @@ -3210,6 +3210,17 @@ NGHTTP2_EXTERN void
nghttp2_option_set_stream_reset_rate_limit(nghttp2_option *option,
uint64_t burst, uint64_t rate);

/**
* @function
*
* This function sets the maximum number of CONTINUATION frames
* following an incoming HEADER frame. If more than those frames are
* received, the remote endpoint is considered to be misbehaving and
* session will be closed. The default value is 8.
*/
NGHTTP2_EXTERN void nghttp2_option_set_max_continuations(nghttp2_option *option,
size_t val);

/**
* @function
*
Expand Down
5 changes: 5 additions & 0 deletions lib/nghttp2_option.c
Expand Up @@ -150,3 +150,8 @@ void nghttp2_option_set_stream_reset_rate_limit(nghttp2_option *option,
option->stream_reset_burst = burst;
option->stream_reset_rate = rate;
}

void nghttp2_option_set_max_continuations(nghttp2_option *option, size_t val) {
option->opt_set_mask |= NGHTTP2_OPT_MAX_CONTINUATIONS;
option->max_continuations = val;
}
5 changes: 5 additions & 0 deletions lib/nghttp2_option.h
Expand Up @@ -71,6 +71,7 @@ typedef enum {
NGHTTP2_OPT_SERVER_FALLBACK_RFC7540_PRIORITIES = 1 << 13,
NGHTTP2_OPT_NO_RFC9113_LEADING_AND_TRAILING_WS_VALIDATION = 1 << 14,
NGHTTP2_OPT_STREAM_RESET_RATE_LIMIT = 1 << 15,
NGHTTP2_OPT_MAX_CONTINUATIONS = 1 << 16,
} nghttp2_option_flag;

/**
Expand Down Expand Up @@ -98,6 +99,10 @@ struct nghttp2_option {
* NGHTTP2_OPT_MAX_SETTINGS
*/
size_t max_settings;
/**
* NGHTTP2_OPT_MAX_CONTINUATIONS
*/
size_t max_continuations;
/**
* Bitwise OR of nghttp2_option_flag to determine that which fields
* are specified.
Expand Down
4 changes: 4 additions & 0 deletions lib/nghttp2_session.c
Expand Up @@ -586,6 +586,10 @@ static int session_new(nghttp2_session **session_ptr,
option->stream_reset_burst,
option->stream_reset_rate);
}

if (option->opt_set_mask & NGHTTP2_OPT_MAX_CONTINUATIONS) {
(*session_ptr)->max_continuations = option->max_continuations;
}
}

rv = nghttp2_hd_deflate_init2(&(*session_ptr)->hd_deflater,
Expand Down

0 comments on commit d71a466

Please sign in to comment.