{"record":{"id":"9291d6b8f05d2bed","repo":"valyala/fasthttp","slug":"unsupported-transfer-encoding-q","errorCode":null,"errorMessage":"unsupported transfer-encoding: %q","messagePattern":"unsupported transfer-encoding: %q","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"header.go","lineNumber":3114,"sourceCode":"\t\tcase 't':\n\t\t\tif caseInsensitiveCompare(s.key, strTransferEncoding) {\n\t\t\t\tif h.noHTTP11 {\n\t\t\t\t\tcontinue\n\t\t\t\t}\n\t\t\t\tif transferEncodingSeen {\n\t\t\t\t\th.connectionClose = true\n\t\t\t\t\tif h.secureErrorLogMessage {\n\t\t\t\t\t\treturn 0, ErrUnsupportedTransferEncoding\n\t\t\t\t\t}\n\t\t\t\t\treturn 0, errors.New(\"too many transfer-encoding headers\")\n\t\t\t\t}\n\t\t\t\ttransferEncodingSeen = true\n\t\t\t\tif !caseInsensitiveCompare(s.value, strChunked) {\n\t\t\t\t\th.connectionClose = true\n\t\t\t\t\tif h.secureErrorLogMessage {\n\t\t\t\t\t\treturn 0, ErrUnsupportedTransferEncoding\n\t\t\t\t\t}\n\t\t\t\t\treturn 0, fmt.Errorf(\"unsupported transfer-encoding: %q\", s.value)\n\t\t\t\t}\n\t\t\t\th.contentLength = -1\n\t\t\t\th.h = setArgBytes(h.h, strTransferEncoding, strChunked, argsHasValue)\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tif caseInsensitiveCompare(s.key, strTrailer) {\n\t\t\t\terr := h.SetTrailerBytes(s.value)\n\t\t\t\tif err != nil {\n\t\t\t\t\th.connectionClose = true\n\t\t\t\t\treturn 0, err\n\t\t\t\t}\n\t\t\t\tcontinue\n\t\t\t}\n\t\t}\n\t\th.h = appendArgBytes(h.h, s.key, s.value, argsHasValue)\n\t}\n\n\tif s.err != nil {","sourceCodeStart":3096,"sourceCodeEnd":3132,"githubUrl":"https://github.com/valyala/fasthttp/blob/c96f600972c6f4a7a30d664257b340ebe9d60124/header.go#L3096-L3132","documentation":"fasthttp rejects a Transfer-Encoding header whose value is not 'chunked' (case-insensitive). RFC 7230 only allows 'chunked' as the final transfer coding, so any other value makes the message framing unparseable and fasthttp closes the connection (connectionClose=true). When secureErrorLogMessage is enabled the sentinel ErrUnsupportedTransferEncoding is returned instead of the value-embedding message.","triggerScenarios":"Parsing a request/response whose Transfer-Encoding header is set to something other than 'chunked' or 'identity'-style values — e.g. 'Transfer-Encoding: gzip', 'compress', 'deflate', or a malformed multi-value like 'chunked, gzip' in the wrong order.","commonSituations":"Proxies or clients behind middleware that compresses bodies and rewrites headers; hand-rolled HTTP clients setting Transfer-Encoding instead of Content-Encoding; misconfigured load balancers adding transfer codings.","solutions":["Remove the Transfer-Encoding header and send the body with Content-Length instead, or use exactly 'Transfer-Encoding: chunked'.","If the intent is compression, set Content-Encoding: gzip on the body, not Transfer-Encoding.","Fix the upstream client/proxy that emits the non-chunked transfer coding.","If you control the server and only need to avoid echoing header values in logs, set Server.SecureErrorLogMessage to get the sanitized error."],"exampleFix":"// before (client hand-rolled request)\nreq.Header.Set(\"Transfer-Encoding\", \"gzip\")\n// after\nreq.Header.Set(\"Content-Encoding\", \"gzip\")\nreq.Header.Set(\"Transfer-Encoding\", \"chunked\")","handlingStrategy":"validation","validationCode":"func validTransferEncoding(te string) bool {\n    return strings.EqualFold(strings.TrimSpace(te), \"chunked\") || te == \"\"\n}\n// check before sending: if !validTransferEncoding(te) { fix or drop header }","typeGuard":null,"tryCatchPattern":"var errUnsupportedTE = errors.New(\"unsupported transfer-encoding\")\nif err := server.ServeConn(...); err != nil && strings.Contains(err.Error(), \"unsupported transfer-encoding\") {\n    // close connection / return 400 to client\n}","preventionTips":["Only ever send Transfer-Encoding: chunked","Use Content-Encoding for compression, never Transfer-Encoding","Test clients against a strict HTTP linter (h2spec, net/http roundtrip)"],"tags":["http","fasthttp","transfer-encoding","protocol"],"backgroundTag":"unsupported-transfer-encoding","analyzedSha":"c96f600972c6f4a7a30d664257b340ebe9d60124","analyzedAt":"2026-08-31T22:48:28.265Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T05:18:18.240Z"}