{"id":"4b5f1fc1ef80dc88","repo":"aio-libs/aiohttp","slug":"deflate","errorCode":null,"errorMessage":"deflate","messagePattern":"deflate","errorType":"exception","errorClass":"ContentEncodingError","httpStatus":400,"severity":"error","filePath":"aiohttp/http_parser.py","lineNumber":1207,"sourceCode":"            raise ContentEncodingError(\n                \"Can not decode content-encoding: %s\" % self.encoding\n            )\n\n        if chunk:\n            self.out.feed_data(chunk)\n        return self.decompressor.data_available\n\n    def feed_eof(self) -> None:\n        chunk = self.decompressor.flush()\n        # This should never contain data as we defer the call until exhausting\n        # the decompression. If .flush() is returning data, this may indicate a\n        # zip bomb vulnerability as it will decompress all remaining data at once.\n        assert not chunk\n\n        if self.size > 0:\n            # decompressor is not brotli unless encoding is \"br\"\n            if self.encoding == \"deflate\" and not self.decompressor.eof:  # type: ignore[union-attr]\n                raise ContentEncodingError(\"deflate\")\n\n        self.out.feed_eof()\n\n    def begin_http_chunk_receiving(self) -> None:\n        self.out.begin_http_chunk_receiving()\n\n    def end_http_chunk_receiving(self) -> None:\n        self.out.end_http_chunk_receiving()\n\n\nHttpRequestParserPy = HttpRequestParser\nHttpResponseParserPy = HttpResponseParser\nRawRequestMessagePy = RawRequestMessage\nRawResponseMessagePy = RawResponseMessage\n\nwith suppress(ImportError):\n    if not NO_EXTENSIONS:\n        from ._http_parser import (  # type: ignore[import-not-found,no-redef]","sourceCodeStart":1189,"sourceCodeEnd":1225,"githubUrl":"https://github.com/aio-libs/aiohttp/blob/c0ef574e29109210e96e652771ae4e7b88615fa4/aiohttp/http_parser.py#L1189-L1225","documentation":"ContentEncodingError('deflate') raised in DeflateBuffer.feed_eof when, after consuming all input for a deflate-encoded body, the zlib decompressor reports it has not reached end-of-stream (decompressor.eof is False). This indicates the deflate stream is incomplete/truncated.","triggerScenarios":"On EOF for a deflate body, if size > 0 and `not self.decompressor.eof`, the stream didn't finish cleanly — truncated deflate payload. feed_eof raises ContentEncodingError('deflate').","commonSituations":"Truncated gzip/deflate download; server closing the connection before flushing the final deflate block; proxy truncation; miscomputed Content-Length on a compressed body.","solutions":["Confirm the full deflate stream was delivered (compare against curl --compressed).","Check for truncation by the server/proxy.","Retry; handle as a transport error.","Use Accept-Encoding: identity to bypass if upstream is consistently broken."],"exampleFix":null,"handlingStrategy":"fallback","validationCode":null,"typeGuard":null,"tryCatchPattern":"from aiohttp.http_exceptions import ContentEncodingError\ntry:\n    body = await resp.read()\nexcept ContentEncodingError:\n    # truncated deflate — retry or request identity\n    ...","preventionTips":["Treat incomplete deflate as truncation.","Stream reads to detect truncation earlier."],"tags":["http","compression","deflate","truncated","response"],"analyzedSha":"c0ef574e29109210e96e652771ae4e7b88615fa4","analyzedAt":"2026-08-04T19:51:05.467Z","schemaVersion":2}