{"record":{"id":"002ac5ce1594e368","repo":"ory/hydra","slug":"s-content-encoding-not-supported","errorCode":null,"errorMessage":"%s content encoding not supported","messagePattern":"(.+?) content encoding not supported","errorType":"http","errorClass":null,"httpStatus":null,"severity":"error","filePath":"oryx/httpx/gzip_server.go","lineNumber":45,"sourceCode":"\treturn &CompressionRequestReader{\n\t\tErrHandler: eh,\n\t}\n}\n\nfunc (c *CompressionRequestReader) ServeHTTP(w http.ResponseWriter, r *http.Request, next http.HandlerFunc) {\n\tfor _, enc := range strings.Split(r.Header.Get(\"Content-Encoding\"), \",\") {\n\t\tswitch enc = strings.TrimSpace(enc); enc {\n\t\tcase \"gzip\":\n\t\t\treader, err := gzip.NewReader(r.Body)\n\t\t\tif err != nil {\n\t\t\t\tc.ErrHandler(w, r, err)\n\t\t\t\treturn\n\t\t\t}\n\t\t\tr.Body = io.NopCloser(reader)\n\t\tcase \"identity\", \"\":\n\t\t\t// nothing to do\n\t\tdefault:\n\t\t\tc.ErrHandler(w, r, fmt.Errorf(\"%s content encoding not supported\", enc))\n\t\t}\n\t}\n\n\tnext(w, r)\n}\n","sourceCodeStart":27,"sourceCodeEnd":51,"githubUrl":"https://github.com/ory/hydra/blob/4174065ffb052799890f7480f5360a877a67ffc1/oryx/httpx/gzip_server.go#L27-L51","documentation":"The gzip_server middleware only knows how to decode request bodies with Content-Encoding values gzip, identity, or the empty string. Any other encoding (br, deflate, zstd, etc.) is handed to the configured error handler with this error and the request never reaches the next handler with a decoded body.","triggerScenarios":"An HTTP client sends a request to a handler wrapped by this middleware with a Content-Encoding header other than gzip/identity, e.g. curl --data-binary --compressed with br, or an SDK that transparently compresses payloads with deflate/zstd.","commonSituations":"Clients behind proxies or CDNs that add Content-Encoding: br; misconfigured HTTP clients that set deflate; load tests with zstd-compressed bodies; developers assuming the middleware supports all standard encodings.","solutions":["Change the client to send Content-Encoding: gzip (or no encoding) for requests to this endpoint","Add a case for the needed encoding in the middleware (e.g. via compress/gzip-like reader for that format)","Reject unsupported encodings earlier at the gateway/proxy with a clear 415 response","Return 415 Unsupported Media Type from the ErrHandler so clients get a meaningful status instead of a 500"],"exampleFix":"// before\ncurl -X POST --data-binary @req.br -H 'Content-Encoding: br' https://api/endpoint\n// after\ngzip -c req.json | curl -X POST --data-binary @- -H 'Content-Encoding: gzip' https://api/endpoint","handlingStrategy":"validation","validationCode":"func preflight(r *http.Request) error {\n    switch r.Header.Get(\"Content-Encoding\") {\n    case \"\", \"gzip\", \"identity\":\n        return nil\n    default:\n        return fmt.Errorf(\"unsupported Content-Encoding %q; use gzip or identity\", r.Header.Get(\"Content-Encoding\"))\n    }\n}","typeGuard":"func isSupportedEncoding(enc string) bool {\n    switch enc {\n    case \"\", \"identity\", \"gzip\":\n        return true\n    }\n    return false\n}","tryCatchPattern":"if err := client.Do(req); err != nil {\n    var herr interface{ StatusCode() int }\n    if errors.As(err, &herr) && herr.StatusCode() == http.StatusUnsupportedMediaType {\n        // resend without Content-Encoding or with gzip\n    }\n}","preventionTips":["Set Content-Encoding: gzip explicitly (or omit it) in clients hitting gzip-decoding middleware","Audit proxies/CDNs for automatic br/deflate re-compression of request bodies","Test every client integration against the endpoint with its real headers","Document supported encodings in the API contract"],"tags":["http","middleware","content-encoding","go"],"backgroundTag":"unsupported-content-encoding","analyzedSha":"4174065ffb052799890f7480f5360a877a67ffc1","analyzedAt":"2026-09-03T14:52:41.581Z","contentChangedAt":"2026-09-03T14:52:41.581Z","schemaVersion":2},"datasetVersion":"2026-09-10T17:17:09.494Z"}