-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Increase HTTP header size limit in Netty-based HttpClients #45291
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
base: main
Are you sure you want to change the base?
Increase HTTP header size limit in Netty-based HttpClients #45291
Conversation
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.
Pull Request Overview
This PR increases the maximum HTTP header size in Netty-based HTTP clients (and related test servers) from 8 KB to 16 KB while keeping the value hard-coded. Key changes include updating HttpConfiguration in the test and server setups, adding max header size in Vert.x, Netty, and OkHttp builders, and revising tests to reflect the new header size limits.
Reviewed Changes
Copilot reviewed 13 out of 13 changed files in this pull request and generated 1 comment.
Show a summary per file
File | Description |
---|---|
sdk/core/azure-core/src/test/java/com/azure/core/validation/http/LocalTestServer.java | Updated HttpConfiguration to use a max header size of 16 KB. |
sdk/core/azure-core/src/test/java/com/azure/core/validation/http/HttpClientTestsServer.java | Revised endpoint constants and added the pathMatches helper for routing tests. |
sdk/core/azure-core/src/test/java/com/azure/core/validation/http/HttpClientTests.java | Updated tests to use RETURN_BYTES instead of EXPECTED_RETURN_BYTES and added tests for huge headers. |
sdk/core/azure-core-http-vertx/src/main/java/com/azure/core/http/vertx/VertxHttpClientBuilder.java | Set max header size in the HttpClientOptions to 16 KB. |
sdk/core/azure-core-http-okhttp/* | Minor improvements in builder method chaining and import adjustments. |
sdk/core/azure-core-http-netty/* | Integrated max header size into the Netty decoder configuration. |
sdk/clientcore/* | Similar updates for test servers and clients ensuring consistency with the increased header size. |
sdk/core/azure-core/src/test/java/com/azure/core/validation/http/HttpClientTestsServer.java
Show resolved
Hide resolved
Alan, from my test, the Netty one seems also the combined size. (I've repurposed a local function to test -- httpbin does have
curl on it
|
Thanks for that further investigation @weidongxu-microsoft, it was a bit unclear to me when I was reading through Netty's code on how this was handled in the end. Will update the description and dig further into whether this should be a more easily configured option on Netty and Vert.x HttpClients. |
@@ -56,6 +56,25 @@ HttpClient client = new VertxHttpClientBuilder() | |||
.build(); | |||
``` | |||
|
|||
### Create an HttpClient with custom maxHeaderSize | |||
|
|||
Create a Netty HttpClient that uses a custom maxHeaderSize. Use this sample if you're seeing an error such as |
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.
should it be vertx client?
|
||
@Timeout(value = 1, unit = TimeUnit.MINUTES) | ||
@Test | ||
public void canSendTinyBinaryDataDebugging() throws IOException { |
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.
did you remove the test intentionally?
Description
Increases Netty's max header size to accomadate headers that are larger than 8 KB. The initial draft of this PR is to increase this to 16 KB but continue hard coding it.
At this time there are four unique HTTP stacks supported, JDK HttpClient, Netty, OkHttp, and Vert.x, all with slightly different handling.
JDK HttpClient tracks the size of all HTTP headers processed, with a default size limit of 384 KB, and can be configured by modifying the system property
jdk.http.maxHeaderSize
. Changing this will affect behavior of the JDK HttpClient itself and usages ofHttpURLConnection
. We haven't seen any concerns with this, but modifying this behavior would affect more than just Azure SDK code.Netty uses the behavior mentioned in this PR, with tracking the size of individual HTTP headers. The default limit is 8 KB and this can be configured by modifying theHttpDecoderConfig
(as seen in this PR). Modifying this only changes the Netty HttpClient built, so should be safe to mutate as it only effect a single HttpClient.OkHttp is the same as the JDK HttpClient, where it tracks all HTTP headers processed, but default to 256 KB and doesn't appear to be mutable. This could cause issues in the future if services return both many and large headers.
Vert.x is the same as Netty, where it tracks individual HTTP headers, uses the same default, and works on a per-HttpClient level. The only difference is this is a modification toHttpClientOptions
.Per Weidong's comment the Netty and Vert.x sections were wrong. They too work on the entire size of all HTTP headers processed. Default is still 8 KB and the way to configure them is still the same though. But given how restrictive the size is, 16 KB that is hardcoded in this PR is unlikely to be sufficient long term and exposing a configuration for this may be warranted.
All SDK Contribution checklist:
General Guidelines and Best Practices
Testing Guidelines