Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
enable WINHTTP_OPTION_REQUIRE_STREAM_END on request handles
  • Loading branch information
antonfirsov authored and github-actions committed Jan 4, 2022
commit eae9fbce14d5ea07e322ab0b07163aabecf979f4
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,7 @@ internal static partial class WinHttp

public const uint WINHTTP_OPTION_TCP_KEEPALIVE = 152;
public const uint WINHTTP_OPTION_STREAM_ERROR_CODE = 159;
public const uint WINHTTP_OPTION_REQUIRE_STREAM_END = 160;

public enum WINHTTP_WEB_SOCKET_BUFFER_TYPE
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1534,6 +1534,22 @@ private void SetRequestHandleHttp2Options(SafeWinHttpHandle requestHandle, Versi
{
if (NetEventSource.Log.IsEnabled()) NetEventSource.Info(this, "HTTP/2 option not supported");
}

if (requestVersion == HttpVersion20 && WinHttpTrailersHelper.OsSupportsTrailers)
{
// Setting WINHTTP_OPTION_REQUIRE_STREAM_END to TRUE is needed for WinHttp to read trailing headers
// in case the response has Content-Lenght defined.
// According to the WinHttp team, the feature-detection logic in WinHttpTrailersHelper.OsSupportsTrailers
// should also indicate the support of WINHTTP_OPTION_REQUIRE_STREAM_END.
optionData = 1;
if (!Interop.WinHttp.WinHttpSetOption(requestHandle, Interop.WinHttp.WINHTTP_OPTION_REQUIRE_STREAM_END, ref optionData))
{
if (NetEventSource.Log.IsEnabled())
{
NetEventSource.Info(this, "Failed to enable WINHTTP_OPTION_REQUIRE_STREAM_END error code: " + Marshal.GetLastWin32Error());
}
}
}
}

private void SetWinHttpOption(SafeWinHttpHandle handle, uint option, ref uint optionData)
Expand Down