Enforce a 4K limit for HTTP/3, like HTTP/2

This commit is contained in:
Frank Denis 2026-10-10 20:47:43 +02:00
parent 9cf4bb6822
commit ade0c1d682
2 changed files with 9 additions and 3 deletions

View file

@ -33,7 +33,8 @@ type CryptoConstruct
)
const (
MaxHTTPBodyLength = 1000000
MaxHTTPBodyLength = 1000000
MaxHTTPResponseHeaderBytes = 4096
)
var (

View file

@ -295,7 +295,7 @@ func (xTransport *XTransport) rebuildTransport() {
IdleConnTimeout: DefaultIdleConnTimeout,
ResponseHeaderTimeout: timeout,
ExpectContinueTimeout: timeout,
MaxResponseHeaderBytes: 4096,
MaxResponseHeaderBytes: MaxHTTPResponseHeaderBytes,
DialContext: func(ctx context.Context, network, addrStr string) (net.Conn, error) {
host, port := ExtractHostAndPort(addrStr, stamps.DefaultPort)
formatEndpoint := func(ip net.IP) string {
@ -500,7 +500,12 @@ type udpTarget struct {
}
return nil, lastErr
}
h3Transport := &http3.Transport{DisableCompression: true, TLSClientConfig: &tlsClientConfig, Dial: dial}
h3Transport := &http3.Transport{
DisableCompression: true,
TLSClientConfig: &tlsClientConfig,
MaxResponseHeaderBytes: MaxHTTPResponseHeaderBytes,
Dial: dial,
}
xTransport.h3Transport = h3Transport
}
}