XX-net/XX-Net · warning

entity header:%s

Error message

entity header:%s

What it means

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.

Source

Thrown at code/default/gae_proxy/local/proxy_handler.py:324

            except NetWorkIOError as e:
                xlog.error('handle_method_urlfetch read payload failed:%s', e)
                return
        elif b'Transfer-Encoding' in self.headers:
            # chunked, used by facebook android client
            payload = ""
            while True:
                chunk_size_str = self.rfile.readline(65537)
                chunk_size_list = chunk_size_str.split(b";")
                chunk_size = int(b"0x"+chunk_size_list[0], 0)
                if len(chunk_size_list) > 1 and chunk_size_list[1] != b"\r\n":
                    xlog.warn("chunk ext: %s", chunk_size_str)
                if chunk_size == 0:
                    while True:
                        line = self.rfile.readline(65537)
                        if line == b"\r\n":
                            break
                        else:
                            xlog.warn("entity header:%s", line)
                    break
                payload += self.rfile.read(chunk_size)
                get_crlf(self.rfile)

        self.req_payload = payload
        return payload

# called by smart_router
def wrap_ssl(sock, host, port, client_address):
    certfile = CertUtil.get_cert(host or b'www.google.com')
    ssl_sock = ssl.wrap_socket(sock, keyfile=CertUtil.cert_keyfile,
                               certfile=certfile, server_side=True)
    return ssl_sock

View on GitHub (pinned to cfa5bc17b6)

Solutions

  1. Inspect the logged line to see what the client actually sent
  2. Fix the client/middlebox to emit spec-compliant chunked encoding (size CRLF data CRLF, 0 CRLF CRLF)
  3. If trailers are expected, extend the parser to handle them explicitly
Defensive patterns

Strategy: validation

Validate before calling

// Ensure chunked requests are well-formed before proxying: send size CRLF data CRLF and terminate with '0\r\n\r\n'

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of XX-net/XX-Net@cfa5bc17b6 (2026-08-27). Data as JSON: /api/errors/4e65d9f97afa3637. Report an issue: GitHub.