{"record":{"id":"aace526b7ee6f3d7","repo":"valyala/fasthttp","slug":"unsupported-http-version-q-in-q","errorCode":null,"errorMessage":"unsupported http version %q in %q","messagePattern":"unsupported http version %q in %q","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"header.go","lineNumber":2876,"sourceCode":"\t}\n\tif len(statusCode) != 3 {\n\t\tif h.secureErrorLogMessage {\n\t\t\treturn 0, ErrUnexpectedStatusCodeChar\n\t\t}\n\t\treturn 0, fmt.Errorf(\"invalid response status code %q: response %q\", statusCode, buf)\n\t}\n\th.statusCode, n, err = parseUintBuf(statusCode)\n\tif err != nil || n != 3 {\n\t\tif h.secureErrorLogMessage {\n\t\t\treturn 0, ErrUnexpectedStatusCodeChar\n\t\t}\n\t\treturn 0, fmt.Errorf(\"invalid response status code %q: response %q\", statusCode, buf)\n\t}\n\tif !isHTTPVersion(protoStr) {\n\t\tif h.secureErrorLogMessage {\n\t\t\treturn 0, fmt.Errorf(\"unsupported http version %q\", protoStr)\n\t\t}\n\t\treturn 0, fmt.Errorf(\"unsupported http version %q in %q\", protoStr, buf)\n\t}\n\th.noHTTP11 = !bytes.Equal(protoStr, strHTTP11)\n\th.protocol = append(h.protocol[:0], protoStr...)\n\tif len(statusMessage) > 0 {\n\t\th.SetStatusMessage(statusMessage)\n\t}\n\n\treturn len(buf) - len(bNext), nil\n}\n\nfunc isValidMethod(method []byte) bool {\n\tfor _, ch := range method {\n\t\tif validMethodValueByteTable[ch] == 0 {\n\t\t\treturn false\n\t\t}\n\t}\n\treturn true\n}","sourceCodeStart":2858,"sourceCodeEnd":2894,"githubUrl":"https://github.com/valyala/fasthttp/blob/c96f600972c6f4a7a30d664257b340ebe9d60124/header.go#L2858-L2894","documentation":"The protocol token at the start of the response status line is not a recognizable HTTP version (HTTP/1.0, HTTP/1.1, etc.). fasthttp throws this, including the raw response, when the first line begins with something other than a valid HTTP version string.","triggerScenarios":"ResponseHeader.parseFirstLine: bytes.IndexByte found a space, but b[:n] (protoStr) fails isHTTPVersion — e.g. response starts with '<html>', 'SSH-2.0', or TLS alert bytes.","commonSituations":"Speaking plain HTTP to an HTTPS-only port (receiving TLS binary), hitting an SSH/SMTP/HTML service, DNS or firewall interstitials, HTTP/2 prior-knowledge endpoints that reject HTTP/1.1 framing.","solutions":["Verify the endpoint scheme and port with curl -v; use https:// plus a TLS-enabled fasthttp.Client if required","Check you are not connecting to a non-HTTP service on that port","If the server requires HTTP/2, use a client that supports it (net/http with ForceAttemptHTTP2) instead of fasthttp","Inspect the echoed %q response body to identify exactly what the peer sent"],"exampleFix":"// before\nfasthttp.Get(nil, \"http://example.com:443/\")\n// after\nfasthttp.Get(nil, \"https://example.com/\")","handlingStrategy":"try-catch","validationCode":"resp, err := http.Get(url) // sanity check endpoint speaks HTTP with std client first\nif err != nil { return err }\nresp.Body.Close()","typeGuard":"func isUnsupportedHTTPVersion(err error) bool {\n    return err != nil && strings.Contains(err.Error(), \"unsupported http version in\")\n}","tryCatchPattern":"err := client.Do(req, resp)\nif err != nil && strings.Contains(err.Error(), \"unsupported http version\") {\n    log.Error(\"peer is not speaking HTTP/1.x\", \"endpoint\", req.URI(), \"err\", err)\n    return errBadUpstream\n}","preventionTips":["curl -v unfamiliar endpoints before wiring them into fasthttp clients","Use https/TLS client for HTTPS ports; never plain HTTP on :443","Route HTTP/2-only services through net/http instead of fasthttp","Alert on this error — it almost always signals endpoint misconfiguration"],"tags":["http","protocol-version","response-parsing","fasthttp"],"backgroundTag":"unsupported-http-version","analyzedSha":"c96f600972c6f4a7a30d664257b340ebe9d60124","analyzedAt":"2026-08-31T22:48:28.265Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T05:18:18.240Z"}