-
Notifications
You must be signed in to change notification settings - Fork 5.5k
codec: Raise max_request_headers_kb limit to 96 KiB #5859
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 6 commits
fdd1442
932eaf0
999b247
6e2e092
1ba5e19
51e8fb7
37d6900
8c1be4a
d3e146d
d14f019
7fae643
6c6cd5c
87cd65b
12cb34d
2370471
7aba9ea
dc0b47e
e241e35
cff066e
358fd16
bbf0df2
c8b006e
8bb762c
3bcfbdf
56644a1
7ece1c7
5210dda
0f7911c
9bce125
7fb8701
19d10a2
b55c483
6473a65
e084dc7
c7ec56b
f520e89
4a5d64e
9a20bb5
bfbeed4
e28fcdb
be85a3f
b5ba8ef
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -913,6 +913,54 @@ TEST_P(Http2CodecImplTest, TestLargeHeadersAtLimitAccepted) { | |
| request_encoder_->encodeHeaders(request_headers, true); | ||
| } | ||
|
|
||
| TEST_P(Http2CodecImplTest, TestLargeHeadersOverDefaultCodecLimit) { | ||
| max_request_headers_kb_ = 100; | ||
| initialize(); | ||
|
|
||
| TestHeaderMapImpl request_headers; | ||
| HttpTestUtility::addDefaultHeaders(request_headers); | ||
| std::string long_string = std::string(65 * 1024, 'q'); | ||
| request_headers.addCopy("big", long_string); | ||
|
|
||
| EXPECT_CALL(request_decoder_, decodeHeaders_(_, _)).Times(1); | ||
| EXPECT_CALL(server_stream_callbacks_, onResetStream(_)).Times(0); | ||
| request_encoder_->encodeHeaders(request_headers, true); | ||
| } | ||
|
|
||
| TEST_P(Http2CodecImplTest, TestManyLargeHeadersWayOverDefaultCodecLimit) { | ||
| max_request_headers_kb_ = 100; | ||
| initialize(); | ||
|
|
||
| TestHeaderMapImpl request_headers; | ||
| HttpTestUtility::addDefaultHeaders(request_headers); | ||
| std::string long_string = std::string(1024, 'q'); | ||
| for (int i = 0; i < 80; i++) { | ||
| request_headers.addCopy(fmt::format("{}", i), long_string); | ||
| } | ||
|
|
||
| EXPECT_CALL(request_decoder_, decodeHeaders_(_, _)).Times(1); | ||
| EXPECT_CALL(server_stream_callbacks_, onResetStream(_)).Times(0); | ||
| request_encoder_->encodeHeaders(request_headers, true); | ||
| } | ||
|
|
||
| TEST_P(Http2CodecImplTest, TestSingleLargeHeadersWayOverDefaultCodecLimit) { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If your goal is to test an unexpectedly large header frame, you could have several keys with fairly long strings.
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Already had a test with several long strings! But I rearranged/reworded this stuff. Discussed offline, and I'm going to turn up this test to fail on single-large-header and document the nghttp2 limit in the max_request_headers_kb api. |
||
| // this fails unexpectedly due to the arbitrarily-set NGHTTP2_HD_MAX_NV in lib/nghttp2_hd.h | ||
| // TODO(auni53) turn up this test once that issue is resolved. | ||
| return; | ||
|
|
||
| max_request_headers_kb_ = 100; | ||
| initialize(); | ||
|
|
||
| TestHeaderMapImpl request_headers; | ||
| HttpTestUtility::addDefaultHeaders(request_headers); | ||
| std::string long_string = std::string(80 * 1024, 'q'); | ||
| request_headers.addCopy("big", long_string); | ||
|
|
||
| EXPECT_CALL(request_decoder_, decodeHeaders_(_, _)).Times(1); | ||
| EXPECT_CALL(server_stream_callbacks_, onResetStream(_)).Times(0); | ||
| request_encoder_->encodeHeaders(request_headers, true); | ||
| } | ||
|
|
||
| TEST_P(Http2CodecImplTest, TestCodecHeaderCompression) { | ||
| initialize(); | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -427,6 +427,7 @@ gregs | |
| gzip | ||
| hacky | ||
| handshaker | ||
| hd | ||
| hdr | ||
| healths | ||
| healthz | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isn't this the setting for the size of an individual header frame? I think we want to change the total allowed headers, not the per-frame limits.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IIRC this is not very well named, but I think this does actually set the header send limit, and the library will chunk it into frames using continuation frames if necessary. @auni53 to check me here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could be. I'm not seeing any other size-related fields to tweak. I'd checked
https://nghttp2.org/documentation/nghttp2_option_set_max_send_header_block_length.html
"This option sets the maximum length of header block (a set of header fields per one HEADERS frame) to send. "
It was the "per one HEADERS frame" that got me thinking it might be the wrong field.
in code it's used in prep_frame which I thought was after the chunking but I could easily be misremembering. I'm happy to let Auni do the code sleuthing though :-)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ahh,
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeeee, I'm pretty certain this is the right call. Also because I did this TDD-style and the testing behaviour checks out.