Use http.Transport for non-TLS backends (HTTP/1.1 support)
The h2c-only transport (http2.Transport) fails against backends like Gitea that only speak HTTP/1.1. Switch to standard http.Transport for non-TLS backends, which handles HTTP/1.1 natively and can upgrade to h2c if the backend supports it. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -186,16 +186,16 @@ func newTransport(route RouteConfig) (http.RoundTripper, error) {
|
||||
}, nil
|
||||
}
|
||||
|
||||
// h2c: HTTP/2 over plaintext TCP.
|
||||
return &http2.Transport{
|
||||
AllowHTTP: true,
|
||||
DialTLSContext: func(ctx context.Context, network, addr string, _ *tls.Config) (net.Conn, error) {
|
||||
conn, err := dialBackend(ctx, network, addr, connectTimeout, route)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return conn, nil
|
||||
// Plain HTTP backend. Use standard http.Transport which speaks
|
||||
// HTTP/1.1 by default and can upgrade to h2c if the backend
|
||||
// supports it. This handles backends like Gitea that only speak
|
||||
// HTTP/1.1.
|
||||
return &http.Transport{
|
||||
DialContext: func(ctx context.Context, network, addr string) (net.Conn, error) {
|
||||
return dialBackend(ctx, network, addr, connectTimeout, route)
|
||||
},
|
||||
MaxIdleConnsPerHost: 10,
|
||||
IdleConnTimeout: 90 * time.Second,
|
||||
}, nil
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user