-
Notifications
You must be signed in to change notification settings - Fork 117
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Assume http2 connection by default, instead of http1 #758
Conversation
@swift-server-bot test this please |
@swift-server-bot add to allowlist |
LGTM. I'm wondering if we need to expose this settings not only through |
TIL that we're not already doing that. Seems sensible to default to HTTP/2. Regarding the 'prefer H1' override in public API: Yes, we'll likely need that but that could also be a follow-up? |
agree |
Just out of curiosity what would be a real use case for this? |
Four reasons come to mind:
Today, the vast vast majority of (non-localhost) HTTP/1.x connections are via TLS. I'm not even sure if HTTP/2 is actually more prevalent on the internet than HTTP/1.1, haven't checked. Addition: Actually H2 and H3 should actually be more prevalent given that most of the internet sits behind the same handful of CDNs/Edges which will support H2, even if the upstream servers may only do H1. |
@swift-server-bot test this please |
maximumConnectionUses: nil | ||
) | ||
|
||
var connectionIDs: [HTTPConnectionPool.Connection.ID] = [] | ||
for el in [el1, el2, el2] { | ||
for el in [el1, el2] { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why did you remove el2
here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is because we now directly start with h2 rather than h1 and then migrating to h1.
h2 has checks to not allow creating connections for same EL. The second el2 just fails the test because the check fails.
Sources/AsyncHTTPClient/ConnectionPool/State Machine/HTTPConnectionPool+HTTP1Connections.swift
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for pushing this through!
Since most of the servers now conform to http2, the change here updates the behaviour of assuming the connection to be http2 and not http1 by default. It will migrate to http1 if the server only supports http1.
One can set the
httpVersion
inClientConfiguration
to.http1Only
which will start with http1 instead of http2.Additional Changes: