Skip to content

Commit 06013d3

Browse files
committed
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
1 parent 3597661 commit 06013d3

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

dial.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -328,6 +328,10 @@ func verifyServerResponse(opts *DialOptions, copts *compressionOptions, secWebSo
328328
}
329329

330330
func verifyServerResponseH1(opts *DialOptions, copts *compressionOptions, secWebSocketKey string, resp *http.Response) (*compressionOptions, error) {
331+
if resp.ProtoMajor != 1 {
332+
return nil, fmt.Errorf("expected HTTP/1.x response but got: %s", resp.Proto)
333+
}
334+
331335
if resp.StatusCode != http.StatusSwitchingProtocols {
332336
return nil, fmt.Errorf("expected handshake response status code %v but got %v", http.StatusSwitchingProtocols, resp.StatusCode)
333337
}

0 commit comments

Comments
 (0)