splithttp: Add support for H2C and http/1.1 ALPN on server (#3465)

* Add H2C support to server

* update comment

* Make http1.1 ALPN work on SplitHTTP client

Users that encounter protocol version issues will likely try to set the
ALPN explicitly. In that case we should simply grant their wish, because
the intent is obvious.
This commit is contained in:
mmmray 2024-06-23 19:05:37 +02:00 committed by GitHub
parent 74d233dd64
commit ee2000f6e1
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 68 additions and 9 deletions

View file

@ -58,6 +58,7 @@ func getHTTPClient(ctx context.Context, dest net.Destination, streamSettings *in
}
tlsConfig := tls.ConfigFromStreamSettings(streamSettings)
isH2 := tlsConfig != nil && !(len(tlsConfig.NextProtocol) == 1 && tlsConfig.NextProtocol[0] == "http/1.1")
var gotlsConfig *gotls.Config
@ -88,7 +89,7 @@ func getHTTPClient(ctx context.Context, dest net.Destination, streamSettings *in
var uploadTransport http.RoundTripper
var downloadTransport http.RoundTripper
if tlsConfig != nil {
if isH2 {
downloadTransport = &http2.Transport{
DialTLSContext: func(ctxInner context.Context, network string, addr string, cfg *gotls.Config) (net.Conn, error) {
return dialContext(ctxInner)
@ -121,7 +122,7 @@ func getHTTPClient(ctx context.Context, dest net.Destination, streamSettings *in
upload: &http.Client{
Transport: uploadTransport,
},
isH2: tlsConfig != nil,
isH2: isH2,
uploadRawPool: &sync.Pool{},
dialUploadConn: dialContext,
}