From ced6e9e0ce733669e725a5b1cc952b06f7c05b8d Mon Sep 17 00:00:00 2001 From: Mathias Fredriksson Date: Tue, 16 Dec 2025 16:49:29 +0000 Subject: [PATCH] fix(dial): verify HTTP/1.x protocol in verifyServerResponseH1 Add resp.ProtoMajor check in verifyServerResponseH1 for consistency with verifyServerResponseH2 which already performs this check. Refs #539 --- dial.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/dial.go b/dial.go index da7df341..55256613 100644 --- a/dial.go +++ b/dial.go @@ -328,6 +328,10 @@ func verifyServerResponse(opts *DialOptions, copts *compressionOptions, secWebSo } func verifyServerResponseH1(opts *DialOptions, copts *compressionOptions, secWebSocketKey string, resp *http.Response) (*compressionOptions, error) { + if resp.ProtoMajor != 1 { + return nil, fmt.Errorf("expected HTTP/1.x response but got: %s", resp.Proto) + } + if resp.StatusCode != http.StatusSwitchingProtocols { return nil, fmt.Errorf("expected handshake response status code %v but got %v", http.StatusSwitchingProtocols, resp.StatusCode) }