-
Notifications
You must be signed in to change notification settings - Fork 5.2k
Closed
Description
runtime/src/libraries/System.Net.Http.WinHttpHandler/src/System/Net/Http/WinHttpHandler.cs
Lines 772 to 780 in 19a01d0
int lastError = Marshal.GetLastWin32Error(); | |
if (lastError == Interop.WinHttp.ERROR_INVALID_PARAMETER) | |
{ | |
throw new FormatException(SR.net_http_invalid_header_value); | |
} | |
else | |
{ | |
throw WinHttpException.CreateExceptionUsingError(lastError, nameof(Interop.WinHttp.WinHttpAddRequestHeaders)); | |
} |
runtime/src/libraries/System.Net.Http.WinHttpHandler/src/Resources/Strings.resx
Lines 138 to 140 in 19a01d0
<data name="net_http_invalid_header_value" xml:space="preserve"> | |
<value>Request headers must be valid Latin-1 characters.</value> | |
</data> |
Looks like ERROR_INVALID_PARAMETER
is thrown in more cases than just non-Latin-1, e.g. sending a header name/value longer than 64 KB.
The error is also reported for a subset of [128-159]
(except 129, 141, 143, 144, 157
).
Simple fix here might be to just not throw a specialized exception.