FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

check SwitchingProtocol before ContentLength (#29948) (#29993) · dotnet/corefx@fe653a0 · GitHub

This repository was archived by the owner on Jan 23, 2023. It is now read-only.
/ corefx Public archive

Commit fe653a0

Browse files
authored andcommitted
check SwitchingProtocol before ContentLength (#29948) (#29993)
* check SwitchingProtocol before ContentLength In case some websocket retrun ContentLength =0 with SwitchingProtocol * Update LoopbackHelper To ContentLength: 0 Test Situation when Content-Length: 0 with SwitchingProtocols
1 parent f11f3e1 commit fe653a0

2 files changed

Lines changed: 5 additions & 4 deletions

File tree

‎src/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/HttpConnection.cs‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -616,6 +616,10 @@ public async Task<HttpResponseMessage> SendAsyncCore(HttpRequestMessage request,
616616
_connectionClose = true;
617617

618618
}
619+
else if (response.StatusCode == HttpStatusCode.SwitchingProtocols)
620+
{
621+
responseStream = new RawConnectionStream(this);
622+
}
619623
else if (response.Content.Headers.ContentLength != null)
620624
{
621625
long contentLength = response.Content.Headers.ContentLength.GetValueOrDefault();
@@ -633,10 +637,6 @@ public async Task<HttpResponseMessage> SendAsyncCore(HttpRequestMessage request,
633637
{
634638
responseStream = new ChunkedEncodingReadStream(this);
635639
}
636-
else if (response.StatusCode == HttpStatusCode.SwitchingProtocols)
637-
{
638-
responseStream = new RawConnectionStream(this);
639-
}
640640
else
641641
{
642642
responseStream = new ConnectionCloseReadStream(this);

‎src/System.Net.WebSockets.Client/tests/LoopbackHelper.cs‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ public static async Task<bool> WebSocketHandshakeAsync(LoopbackServer.Connection
2727
string responseSecurityAcceptValue = ComputeWebSocketHandshakeSecurityAcceptValue(headerValue);
2828
serverResponse =
2929
"HTTP/1.1 101 Switching Protocols\r\n" +
30+
"Content-Length: 0\r\n" +
3031
"Upgrade: websocket\r\n" +
3132
"Connection: Upgrade\r\n" +
3233
"Sec-WebSocket-Accept: " + responseSecurityAcceptValue + "\r\n\r\n";

0 commit comments

Comments
 (0)

Back | FazBrowse Home | New Git URL