XX-net/XX-Net · warning
http proxy host can't parsed. %s %s
Error message
http proxy host can't parsed. %s %s
What it means
While handling an absolute-form or proxy-style HTTP request, x_tunnel's http_handler could not find a Host header (or could not parse one into host/port via netloc_to_host_port). The proxy needs the destination host before it can create an outbound connection, so it logs the request line and header block and returns 'HTTP/1.1 500 Fail' to the client.
Source
Thrown at code/default/x_tunnel/local/proxy_handler.py:369
p = url[7:].find(b"/")
if p >= 0:
path = url[7+p:]
else:
path = b"/"
else:
header_block = self.read_headers()
lines = header_block.split(b"\r\n")
path = url
host = None
headers = {}
for line in lines:
key, _, value = line.partition(b":")
headers[key] = value
if key.lower() == b"host":
host, port = netloc_to_host_port(value)
if host is None:
xlog.warn("http proxy host can't parsed. %s %s", req_line, header_block)
self.connection.send(b'HTTP/1.1 500 Fail\r\n\r\n')
return
if url.startswith(b"/openai/"):
content_length = int(headers.get(b"Content-Length", 0))
req_body = self.read_bytes(content_length)
return openai_handler.handle_openai(method, url, headers, req_body, self.connection)
sock = self.connection
conn_id = proxy_session.create_conn(sock, host, port)
if not conn_id:
xlog.warn("http create conn to %s:%d fail", host, port)
sock.send(b'HTTP/1.1 500 Fail\r\n\r\n')
return
xlog.info("http %r connect to %s:%d conn:%d", self.client_address, host, port, conn_id)
new_req_line = b"%s %s %s" % (method, path, http_version)View on GitHub (pinned to cfa5bc17b6)
Solutions
- Fix the client to send a valid 'Host: host[:port]' header on every proxied HTTP/1.1 request.
- Check the logged req_line/header_block in the warning to see exactly what the client sent and which header is missing or malformed.
- If you control the client, prefer origin-form requests with an explicit proxy (absolute URI) so the target can be taken from the request line.
- As a defensive improvement, fall back to parsing the host out of an absolute-form URL when the Host header is absent.
Example fix
# before request = b'GET / HTTP/1.1\r\n\r\n' # no Host header # after request = b'GET / HTTP/1.1\r\nHost: example.com\r\n\r\n'
Defensive patterns
Strategy: validation
Validate before calling
# before proxying, validate the request has a parseable Host
host_header = headers.get(b'Host') or headers.get(b'host')
if not host_header:
conn.send(b'HTTP/1.1 400 Bad Request\r\n\r\n')
else:
proxy.http_handler(req) Prevention
- Always send a Host header in HTTP/1.1 requests through the proxy.
- Validate outgoing request headers in client code before writing to the socket.
When it happens
Trigger: A client sends an HTTP/1.1 request through the local proxy without a Host header (HTTP/1.0-style client), or with a malformed Host value (e.g. 'Host: :8080', empty value, or non-ASCII bytes) that netloc_to_host_port cannot split into host and port.
Common situations: Legacy HTTP/1.0 tools or custom sockets that omit Host; health-check probes (e.g. 'GET / HTTP/1.0') from load balancers; malformed hand-written raw requests in tests; clients sending Host with a value that has no port and breaks the parser.
Related errors
- entity header:%s
- request version:%d error
- request version:%d error
- api:%s fail:%s t:%d
- direct %s %s % status:%d
AI-assisted analysis of XX-net/XX-Net@cfa5bc17b6 (2026-08-27).
Data as JSON: /api/errors/96c003348cad0376.
Report an issue: GitHub.