Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
30da832
downgrade proposal for HttpClient
May 24, 2022
7b03bc8
HttpClient to handle ws over h2
Jun 7, 2022
e7b8332
ClientWebSocket to handle ws over h2
Jun 7, 2022
a5e991a
Add property for protocol header and remove it from known headers
Jun 17, 2022
264c802
Update src/libraries/System.Net.Http/src/System/Net/Http/HttpRequestM…
Jun 18, 2022
08d1f8c
Address review feedback
Jun 18, 2022
71cc887
Rename HttpVersion and HttpVersionPolicy
Jun 20, 2022
8019a3c
Apply suggestions from code review
Jun 21, 2022
8ef8b4c
address review feedback
Jun 21, 2022
ac966a8
Merge branch 'main' into ws-h2-draft
Jun 23, 2022
f6de72a
address review feedback
Jun 24, 2022
9221483
address review feedback
Jun 28, 2022
fafc84b
Apply suggestions from code review
Jun 28, 2022
0d8f8f7
fix race condition on setting enable connect
Jun 29, 2022
9be5b95
inherit h2 read and writes streams
Jun 29, 2022
502b051
Apply suggestions from code review
Jun 30, 2022
e635439
fix H2PACK encoding issue
Jun 30, 2022
ad66857
add timeout for waiting settings task
Jun 30, 2022
c58d993
generalized settings received task
Jun 30, 2022
76c9e20
Update src/libraries/System.Net.Http/src/System/Net/Http/SocketsHttpH…
Jul 1, 2022
2467449
Fixing HttpStream tests
Jul 1, 2022
d9248a6
Apply suggestions from code review
Jul 4, 2022
baf52d4
address review feedback
Jul 4, 2022
afaf5be
Apply suggestions from code review
Jul 8, 2022
918c6a8
Address review feedback
Jul 8, 2022
9734075
Adapt test to ValueTask.FromException
Jul 8, 2022
efdcdba
Apply suggestions from code review
Jul 10, 2022
6f7b101
Adding connect tests
Jul 10, 2022
595642c
Apply suggestions from code review
Jul 10, 2022
e05db11
feedback + skip tests on browser
Jul 10, 2022
54d0b08
Merge branch 'main' into ws-h2-draft
Jul 10, 2022
b7f543b
Feedback + test for websocket stream
Jul 12, 2022
73968ec
Update src/libraries/System.Net.Http/src/Resources/Strings.resx
Jul 12, 2022
4dbe1c2
Address review feedback
Jul 12, 2022
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
HttpClient to handle ws over h2
  • Loading branch information
Katya Sokolova committed Jun 7, 2022
commit 7b03bc8f3319eb1d38e7d8ff538175b543d28683
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,9 @@ private static bool TryGetHeaderName<T>(
}
break;

case 9:
potentialHeader = Protocol; goto TryMatch; // :protocol

case 10:
switch (charAt(key, startIndex))
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ internal static partial class HttpKnownHeaderNames
public const string Origin = "Origin";
public const string P3P = "P3P";
public const string Pragma = "Pragma";
public const string Protocol = ":protocol";
public const string ProxyAuthenticate = "Proxy-Authenticate";
public const string ProxyAuthorization = "Proxy-Authorization";
public const string ProxyConnection = "Proxy-Connection";
Expand Down
1 change: 1 addition & 0 deletions src/libraries/System.Net.Http/ref/System.Net.Http.cs
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,7 @@ public HttpMethod(string method) { }
public static System.Net.Http.HttpMethod Post { get { throw null; } }
public static System.Net.Http.HttpMethod Put { get { throw null; } }
public static System.Net.Http.HttpMethod Trace { get { throw null; } }
public static System.Net.Http.HttpMethod Connect { get { throw null; } }
public bool Equals([System.Diagnostics.CodeAnalysis.NotNullWhen(true)] System.Net.Http.HttpMethod? other) { throw null; }
public override bool Equals([System.Diagnostics.CodeAnalysis.NotNullWhen(true)] object? obj) { throw null; }
public override int GetHashCode() { throw null; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ internal static class KnownHeaders
// If you add a new entry here, you need to add it to TryGetKnownHeader below as well.

public static readonly KnownHeader PseudoStatus = new KnownHeader(":status", HttpHeaderType.Response, parser: null);
public static readonly KnownHeader PseudoProtocol = new KnownHeader(":protocol", HttpHeaderType.Request, parser: null);
public static readonly KnownHeader Accept = new KnownHeader("Accept", HttpHeaderType.Request, MediaTypeHeaderParser.MultipleValuesParser, null, H2StaticTable.Accept, H3StaticTable.AcceptAny);
public static readonly KnownHeader AcceptCharset = new KnownHeader("Accept-Charset", HttpHeaderType.Request, GenericHeaderParser.MultipleValueStringWithQualityParser, null, H2StaticTable.AcceptCharset);
public static readonly KnownHeader AcceptEncoding = new KnownHeader("Accept-Encoding", HttpHeaderType.Request, GenericHeaderParser.MultipleValueStringWithQualityParser, null, H2StaticTable.AcceptEncoding, H3StaticTable.AcceptEncodingGzipDeflateBr);
Expand Down Expand Up @@ -244,7 +245,12 @@ public BytePtrAccessor(byte* p, int length)
break;

case 9:
return ExpectCT; // Expect-CT
switch (key[0] | 0x20)
{
case ':': return PseudoProtocol; // [:]protocol
case 'e': return ExpectCT; // [E]xpect-CT
}
break;

case 10:
switch (key[0] | 0x20)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public static HttpMethod Patch
// Don't expose CONNECT as static property, since it's used by the transport to connect to a proxy.
// CONNECT is not used by users directly.

internal static HttpMethod Connect
public static HttpMethod Connect
{
get { return s_connectMethod; }
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,22 @@ public override string ToString()

internal bool WasRedirected() => (_sendStatus & MessageIsRedirect) != 0;

internal bool IsWebSocketRequest()
{
if (Headers.TryGetValues(":protocol", out IEnumerable<string>? values))
{
var valuesArray = (string[])values;
return valuesArray.Length > 0 && valuesArray[0] == "websocket";
}

if (Headers.TryGetValues("Upgrade", out values))
{
var valuesArray = (string[])values;
return valuesArray.Length > 0 && valuesArray[0] == "websocket";
}
return false;
}

#region IDisposable Members

protected virtual void Dispose(bool disposing)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1899,7 +1899,7 @@ private enum SettingId : ushort
EnableConnect = 0x7
}

internal bool IsWebsocketEnabled { get; private set; } = false;
internal bool IsWebsocketEnabled { get; private set; } = true;

// Note that this is safe to be called concurrently by multiple threads.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -634,7 +634,6 @@ private void OnStatus(int statusCode)
if (_response.RequestMessage != null && _response.RequestMessage.IsWebSocketRequest() && statusCode == 200)
{
_webSocketEstablished = true;
return;
}

_responseProtocolState = ResponseProtocolState.ExpectingHeaders;
Expand Down