{"record":{"id":"4e65d9f97afa3637","repo":"XX-net/XX-Net","slug":"entity-header-s","errorCode":null,"errorMessage":"entity header:%s","messagePattern":"entity header:(.+?)","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"code/default/gae_proxy/local/proxy_handler.py","lineNumber":324,"sourceCode":"            except NetWorkIOError as e:\n                xlog.error('handle_method_urlfetch read payload failed:%s', e)\n                return\n        elif b'Transfer-Encoding' in self.headers:\n            # chunked, used by facebook android client\n            payload = \"\"\n            while True:\n                chunk_size_str = self.rfile.readline(65537)\n                chunk_size_list = chunk_size_str.split(b\";\")\n                chunk_size = int(b\"0x\"+chunk_size_list[0], 0)\n                if len(chunk_size_list) > 1 and chunk_size_list[1] != b\"\\r\\n\":\n                    xlog.warn(\"chunk ext: %s\", chunk_size_str)\n                if chunk_size == 0:\n                    while True:\n                        line = self.rfile.readline(65537)\n                        if line == b\"\\r\\n\":\n                            break\n                        else:\n                            xlog.warn(\"entity header:%s\", line)\n                    break\n                payload += self.rfile.read(chunk_size)\n                get_crlf(self.rfile)\n\n        self.req_payload = payload\n        return payload\n\n# called by smart_router\ndef wrap_ssl(sock, host, port, client_address):\n    certfile = CertUtil.get_cert(host or b'www.google.com')\n    ssl_sock = ssl.wrap_socket(sock, keyfile=CertUtil.cert_keyfile,\n                               certfile=certfile, server_side=True)\n    return ssl_sock\n\n","sourceCodeStart":306,"sourceCodeEnd":339,"githubUrl":"https://github.com/XX-net/XX-Net/blob/cfa5bc17b67676e467f37ec50766127e0ab5f0aa/code/default/gae_proxy/local/proxy_handler.py#L306-L339","documentation":"While reading a chunked HTTP request body in proxy_handler.py, the parser encountered header-like lines after a chunk instead of the terminating CRLF (or inside the trailer). This indicates the upstream client sent a malformed chunked encoding, so the handler skips and logs each unexpected line. It is a protocol-parsing warning, not an exception.","triggerScenarios":"A client sends a chunked request where a chunk is followed by data other than CRLF (e.g. chunk size with extensions, trailers, or raw bytes), causing readline() to return non-empty lines until a blank line is found.","commonSituations":"Non-conforming HTTP clients or middleboxes rewriting chunked bodies; debugging tools sending hand-crafted chunked requests; a chunk_size of 0 with trailing entity headers.","solutions":["Inspect the logged line to see what the client actually sent","Fix the client/middlebox to emit spec-compliant chunked encoding (size CRLF data CRLF, 0 CRLF CRLF)","If trailers are expected, extend the parser to handle them explicitly"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// Ensure chunked requests are well-formed before proxying: send size CRLF data CRLF and terminate with '0\\r\\n\\r\\n'","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Use standard HTTP libraries to produce chunked bodies","Test clients against the proxy with valid chunked samples"],"tags":["http","chunked-encoding","proxy","malformed-request"],"backgroundTag":"malformed-chunked-encoding","analyzedSha":"cfa5bc17b67676e467f37ec50766127e0ab5f0aa","analyzedAt":"2026-08-27T19:28:28.225Z","schemaVersion":2},"datasetVersion":"2026-08-28T00:17:15.603Z"}