{"record":{"id":"79847f3d65bde32d","repo":"HMCL-dev/HMCL","slug":"unsupported-content-encoding","errorCode":null,"errorMessage":"Unsupported content encoding: ","messagePattern":"Unsupported content encoding: ","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"HMCLCore/src/main/java/org/jackhuang/hmcl/util/io/ContentEncoding.java","lineNumber":52,"sourceCode":"        public InputStream wrap(InputStream inputStream) {\n            return inputStream;\n        }\n    },\n    GZIP {\n        @Override\n        public InputStream wrap(InputStream inputStream) throws IOException {\n            return new GZIPInputStream(inputStream);\n        }\n    };\n\n    public static @NotNull ContentEncoding fromConnection(URLConnection connection) throws IOException {\n        String encoding = connection.getContentEncoding();\n        if (encoding == null || encoding.isEmpty() || \"identity\".equals(encoding)) {\n            return IDENTITY;\n        } else if (\"gzip\".equalsIgnoreCase(encoding)) {\n            return GZIP;\n        } else {\n            throw new IOException(\"Unsupported content encoding: \" + encoding);\n        }\n    }\n\n    public static @NotNull ContentEncoding fromHeaders(HttpHeaders headers) throws IOException {\n        String encoding = headers.firstValue(\"content-encoding\").orElse(\"\");\n        if (encoding.isEmpty() || \"identity\".equals(encoding)) {\n            return IDENTITY;\n        } else if (\"gzip\".equalsIgnoreCase(encoding)) {\n            return GZIP;\n        } else {\n            throw new IOException(\"Unsupported content encoding: \" + encoding);\n        }\n    }\n\n    public abstract InputStream wrap(InputStream inputStream) throws IOException;\n}\n","sourceCodeStart":34,"sourceCodeEnd":69,"githubUrl":"https://github.com/HMCL-dev/HMCL/blob/24702dc5a0214034f4c27166d5fd30cad08cec19/HMCLCore/src/main/java/org/jackhuang/hmcl/util/io/ContentEncoding.java#L34-L69","documentation":"ContentEncoding.fromConnection inspects the HttpURLConnection's Content-Encoding header and maps known encodings (none/identity/gzip) to enum constants. Any other encoding value is not handled by HMCL, so an IOException is thrown rather than returning a stream the caller cannot decode.","triggerScenarios":"Calling NetworkUtils download/GET helpers against a server that responds with Content-Encoding values like 'br' (Brotli), 'deflate', 'zstd', or a comma-combined list such as 'gzip, br'.","commonSituations":"Hitting CDNs or modern API endpoints that default to Brotli compression; misconfigured reverse proxies adding encodings; servers echoing an Accept-Encoding the client did not send.","solutions":["Have the server/proxy serve gzip, identity, or no Content-Encoding for this client","Remove 'br' or other exotic encodings from any configured Accept-Encoding request property","If you control the request pipeline, decode the unsupported encoding before passing the connection to HMCL","Patch/wrap fromConnection to support the needed encoding (e.g. Brotli via an InputStream wrapper)"],"exampleFix":"// before\nconnection.setRequestProperty(\"Accept-Encoding\", \"gzip, br\");\n// after\nconnection.setRequestProperty(\"Accept-Encoding\", \"gzip\");","handlingStrategy":"try-catch","validationCode":"String enc = connection.getContentEncoding();\nboolean supported = enc == null || enc.isEmpty() || enc.equals(\"identity\") || enc.equalsIgnoreCase(\"gzip\");\nif (!supported) throw new IOException(\"unsupported Content-Encoding: \" + enc);","typeGuard":null,"tryCatchPattern":"try (InputStream in = NetworkUtils...) { ... }\ncatch (IOException e) {\n    if (e.getMessage().startsWith(\"Unsupported content encoding\")) {\n        // retry without compression or with a different endpoint\n    } else throw e;\n}","preventionTips":["Never send Accept-Encoding values HMCL cannot decode (keep to gzip/identity)","Prefer gzip-only negotiation on HTTP clients","Test downloads against your CDN/proxy before shipping","Audit proxy configurations for encodings injected into responses"],"tags":["io","http","content-encoding"],"backgroundTag":"unsupported-operation","analyzedSha":"24702dc5a0214034f4c27166d5fd30cad08cec19","analyzedAt":"2026-09-10T12:36:46.680Z","contentChangedAt":"2026-09-10T12:36:46.680Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}