Skip to content

Commit 9956989

Browse files
committed
BitConverter.ToUInt64: Explicitly set offset for compatibility with .NET Standard 2.0
1 parent ae900ee commit 9956989

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

StandardSocketsHttpHandler/Net/Http/SocketsHttpHandler/HttpConnection.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,8 @@ internal partial class HttpConnection : IDisposable
3939
private static readonly byte[] s_spaceHttp11NewlineAsciiBytes = Encoding.ASCII.GetBytes(" HTTP/1.1\r\n");
4040
private static readonly byte[] s_httpSchemeAndDelimiter = Encoding.ASCII.GetBytes(Uri.UriSchemeHttp + Uri.SchemeDelimiter);
4141
private static readonly byte[] s_http1DotBytes = Encoding.ASCII.GetBytes("HTTP/1.");
42-
private static readonly ulong s_http10Bytes = BitConverter.ToUInt64(Encoding.ASCII.GetBytes("HTTP/1.0"));
43-
private static readonly ulong s_http11Bytes = BitConverter.ToUInt64(Encoding.ASCII.GetBytes("HTTP/1.1"));
42+
private static readonly ulong s_http10Bytes = BitConverter.ToUInt64(Encoding.ASCII.GetBytes("HTTP/1.0"), 0);
43+
private static readonly ulong s_http11Bytes = BitConverter.ToUInt64(Encoding.ASCII.GetBytes("HTTP/1.1"), 0);
4444

4545
private readonly HttpConnectionPool _pool;
4646
private readonly Socket _socket; // used for polling; _stream should be used for all reading/writing. _stream owns disposal.
@@ -818,7 +818,7 @@ private static void ParseStatusLine(Span<byte> line, HttpResponseMessage respons
818818
ThrowInvalidHttpResponse();
819819
}
820820

821-
ulong first8Bytes = BitConverter.ToUInt64(line.ToArray());
821+
ulong first8Bytes = BitConverter.ToUInt64(line.ToArray(), 0);
822822
if (first8Bytes == s_http11Bytes)
823823
{
824824
response.SetVersionWithoutValidation(HttpVersion.Version11);

0 commit comments

Comments
 (0)