Open Tratcher opened 2 years ago
Tagging subscribers to this area: @dotnet/ncl See info in area-owners.md if you want to be subscribed.
Author: | Tratcher |
---|---|
Assignees: | - |
Labels: | `api-suggestion`, `area-System.Net` |
Milestone: | - |
Workaround: Check if the HttpStatusCode returns 101 (HTTP/1.1) or 200 (HTTP/2). Note you need to enable CollectHttpResponseDetails for HttpStatusCode to be populated (weird).
Some discussion around that: https://github.com/dotnet/runtime/pull/71757#discussion_r915907922. Version
may be similar here.
I agree we should let you query Version
even if CollectHttpResponseDetails
isn't set (worst-case it's Unknown as you point out).
Triage: We could leverage the HttpVersion.Unknown
when the info is not available (e.g. in Browser) or follow pattern of StatusCode. We need a decision, ideally in 8.0. Implementation afterwards will be simple.
triage: not urgent, moving to future.
Background and motivation
.NET 7 now supports WebSockets over HTTP/2. ClientWebSocket can negotiate with the server to choose HTTP/1.1 or HTTP/2 based on what's available. However, there's not an easy way to determine which protocol was used. HttpResponseMessage has the Version field to let you know this, but ClientWebSocket does not.
This information is mainly useful for testing, logging, diagnostics, etc., the WebSocket works the same either way.
API Proposal
API Usage
Alternative Designs
Workaround: Check if the HttpStatusCode returns 101 (HTTP/1.1) or 200 (HTTP/2). Note you need to enable CollectHttpResponseDetails for HttpStatusCode to be populated (weird).
Risks
No response