Skip to content

Increase HTTP header line size limit during deserialization of HttpRequestMessage #307

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

Closed
aturabi opened this issue Oct 5, 2021 · 0 comments · Fixed by #312
Closed

Increase HTTP header line size limit during deserialization of HttpRequestMessage #307

aturabi opened this issue Oct 5, 2021 · 0 comments · Fixed by #312
Assignees
Labels
Milestone

Comments

@aturabi
Copy link

aturabi commented Oct 5, 2021

Getting "Error parsing HTTP message header byte 2048 of message System.Byte[]" error when deserializing HttpRequestMessage, asking to get HTTP header line size limit to match whatever limits are in place for HttpRequestMessage and serialization

When calling the method 'HttpContentMessageExtensions.ReadAsHttpRequestMessageAsync' (https://docs.microsoft.com/en-us/previous-versions/aspnet/hh834457(v%3dvs.118)) in System.Net.Http.Formatting to deserialize an HTTP message, I am sometimes getting the error "Error parsing HTTP message header byte 2048 of message System.Byte[]".

This HTTP header line size is not a value that can be adjusted by any of the method's input parameters.

If this value is going to be hard-coded (and the user is not able to pass them in), it would be great if it could at least honor the HTTP header line size limits for the actual HTTP request message object, and the limits for the serialization. (Why are we able to populate an obj with HTTP headers this size, and serialize it without any error but deserialization gets an error?)

Someone else with same issue: https://forums.asp.net/t/2037342.aspx?Max+header+size+when+serializing+HttpMessageContent

@mkArtakMSFT mkArtakMSFT added this to the 3.2.8 milestone Oct 25, 2021
pranavkm added a commit that referenced this issue Jan 14, 2022
As part of ReadAsHttpRequestMessageAsync, the parsing of the HTTP request line is limited
by a non-configurable 2k limit. The size does not affect buffer sizes, only the maximum allowed length.

This PR updates the ReadAsHttpRequestMessageAsync API to use the same limits for HTTP request line
as the HTTP header line, the latter which is configurable by user code.
In the default case, this means the HTTP request line size now supports a 16k limit before it throws.

Fixes #307
pranavkm added a commit that referenced this issue Jan 14, 2022
#312)

* Configure max request line size limits to be the same as maxHeaderSize

As part of ReadAsHttpRequestMessageAsync, the parsing of the HTTP request line is limited
by a non-configurable 2k limit. The size does not affect buffer sizes, only the maximum allowed length.

This PR updates the ReadAsHttpRequestMessageAsync API to use the same limits for HTTP request line
as the HTTP header line, the latter which is configurable by user code.
In the default case, this means the HTTP request line size now supports a 16k limit before it throws.

Fixes #307
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants