{"record":{"id":"51af052a8b457541","repo":"XX-net/XX-Net","slug":"https-req-line-fail-s-51af05","errorCode":null,"errorMessage":"https req line fail:%s","messagePattern":"https req line fail:(.+?)","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"code/default/x_tunnel/local/proxy_handler.py","lineNumber":301,"sourceCode":"            xlog.warn(\"socks5 %r connect to %s:%d conn_id:%d closed:%r\", self.client_address, addr, port, conn_id, e)\n            return\n\n        if len(self.read_buffer) - self.buffer_start:\n            g.session.conn_list[conn_id].transfer_received_data(self.read_buffer[self.buffer_start:])\n\n        g.session.conn_list[conn_id].start(block=True)\n\n    def https_handler(self):\n        line = self.read_crlf_line()\n        line = line.decode('iso-8859-1')\n        words = line.split()\n        if len(words) == 3:\n            command, path, version = words\n        elif len(words) == 2:\n            command, path = words\n            version = b\"HTTP/1.1\"\n        else:\n            xlog.warn(\"https req line fail:%s\", line)\n            return\n\n        if command != \"ONNECT\":\n            xlog.warn(\"https req line fail:%s\", line)\n            return\n\n        host, _, port = path.rpartition(':')\n        host = host.encode()\n        port = int(port)\n\n        header_block = self.read_headers()\n\n        sock = self.connection\n        conn_id = proxy_session.create_conn(sock, host, port)\n        if not conn_id:\n            xlog.warn(\"https create conn to %s:%d fail\", host, port)\n            sock.send(b'HTTP/1.1 500 Fail\\r\\n\\r\\n')\n            return","sourceCodeStart":283,"sourceCodeEnd":319,"githubUrl":"https://github.com/XX-net/XX-Net/blob/cfa5bc17b67676e467f37ec50766127e0ab5f0aa/code/default/x_tunnel/local/proxy_handler.py#L283-L319","documentation":"The HTTPS CONNECT request line could not be parsed into 2 or 3 whitespace-separated words, so the proxy rejects the handshake. Indicates a malformed CONNECT line from the client.","triggerScenarios":"Client sends a request line like 'CONNECT' alone, extra spaces, or a non-HTTP line to the proxy port in 'C' mode.","commonSituations":"Malformed hand-rolled HTTP client, or protocol desync where buffered bytes from a previous request are misinterpreted.","solutions":["Use a proper HTTP library for CONNECT (requests/curl handle it)","Ensure the client sends 'CONNECT host:port HTTP/1.1'","Check for leftover pipelined bytes if desync is suspected"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"words = line.split()\nassert 2 <= len(words) <= 3 and words[0] == b'CONNECT'","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Use standard HTTP libraries that emit valid CONNECT lines"],"tags":["x-tunnel","http-proxy","connect","malformed-request"],"backgroundTag":"malformed-http-request","analyzedSha":"cfa5bc17b67676e467f37ec50766127e0ab5f0aa","analyzedAt":"2026-08-27T19:28:28.225Z","schemaVersion":2},"datasetVersion":"2026-08-28T00:17:15.603Z"}