-
Notifications
You must be signed in to change notification settings - Fork 4.9k
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
WinHttp: always read HTTP/2 streams to the end #62870
Conversation
Tagging subscribers to this area: @dotnet/ncl Issue DetailsIn it's default behavior, WinHttp stops reading the stream when I don't fully understand the impact of applying The PR also adds equivalent Fixes #60291
|
Stream end is a http2 and http3 concept. I assume it has no impact on http11. Probably worth double checking with winhttp folks. I would like a unit test of a http2 server returning more content than its content-length defines. We can check what socketshttphandler does, what winhttphandler does today (pre-pr) and what it does after adding this flag. My experience is in the server side of http, but there we validate the content length and error if doesn’t match the actual content. Correct me if I’m wrong @Tratcher :) |
The HTTP/2 spec says having a Content-Length mismatch the total data frames is a stream level protocol violation and should result in RST. It's worth confirming WinHttp enforces that. |
Ok! As long as the impact of the setting is understood then I’m fine with looking at content-length separately. |
/azp run runtime-libraries-coreclr outerloop |
Azure Pipelines successfully started running 1 pipeline(s). |
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.
{ | ||
if (NetEventSource.Log.IsEnabled()) | ||
{ | ||
NetEventSource.Info(this, "Failed to enable WINHTTP_OPTION_REQUIRE_STREAM_END error code: " + Marshal.GetLastWin32Error()); |
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.
NetEventSource.Info(this, $"Failed to enable WINHTTP_OPTION_REQUIRE_STREAM_END error code: {Marshal.GetLastWin32Error()}");
/backport to release/6.0 |
Started backporting to release/6.0: https://github.com/dotnet/runtime/actions/runs/1654653739 |
By it's default behavior, WinHttp stops reading the stream when
Content-Length
is specified, this prevents us to read the remaining trailers. By opting in intoWINHTTP_OPTION_REQUIRE_STREAM_END
,WinHttpHandler
behavior becomes equivalent ofSocketsHttpHandler
. Note that this means if the actual data is longer thanContent-Length
, we will read all the extra data bytes in both handlers, which we probably shouldn't do, but that's a topic we should investigate separately.I don't fully understand the impact of applying
WINHTTP_OPTION_REQUIRE_STREAM_END
in HTTP/1.1, so I'm applying it only for HTTP 2.0 requests.The PR also adds equivalent
Content-Length
tests for SocketsHttpHandler for consistency.Fixes #60291
/cc @JamesNK