{"record":{"id":"7da6bb06458e3ff3","repo":"XX-net/XX-Net","slug":"https-req-line-fail-s","errorCode":null,"errorMessage":"https req line fail:%s","messagePattern":"https req line fail:(.+?)","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"code/default/smart_router/local/proxy_handler.py","lineNumber":314,"sourceCode":"        reply = b\"\\x05\\x00\\x00\" + addrtype_pack + addr_pack + struct.pack(\">H\", port)\n        sock.send(reply)\n\n        if addrtype in [1, 4]:\n            handle_ip_proxy(sock, addr, port, self.client_address)\n        else:\n            handle_domain_proxy(sock, addr, port, self.client_address)\n\n    def https_handler(self):\n        line = self.read_crlf_line()\n        line = line\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 != b\"CONNECT\":\n            xlog.warn(\"https req line fail:%s\", line)\n            return\n\n        host, _, port = path.rpartition(b':')\n        port = int(port)\n\n        header_block = self.read_headers()\n        sock = self.conn\n\n        # xlog.debug(\"https %r connect to %s:%d\", self.client_address, host, port)\n        sock.send(b'HTTP/1.1 200 OK\\r\\n\\r\\n')\n\n        handle_domain_proxy(sock, host, port, self.client_address)\n\n    def http_handler(self):","sourceCodeStart":296,"sourceCodeEnd":332,"githubUrl":"https://github.com/XX-net/XX-Net/blob/cfa5bc17b67676e467f37ec50766127e0ab5f0aa/code/default/smart_router/local/proxy_handler.py#L296-L332","documentation":"The CONNECT request line in https_handler could not be parsed into 2 or 3 whitespace-separated tokens. The handler aborts the tunnel setup.","triggerScenarios":"First line of the request is malformed (not 'CONNECT host:port HTTP/x.y'), e.g. wrong method spelling or missing target.","commonSituations":"A client sending a plain GET to the HTTPS-tunnel path, manual telnet/netcat testing with typos, or a protocol detector misrouting the connection.","solutions":["Log the offending line and fix the client to send a proper CONNECT request","Ensure the connection is routed to http_handler for non-CONNECT methods","Check for leading garbage/newline corruption before the request line"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"parts = line.split(); assert 2 <= len(parts) <= 3 and parts[0] == b'CONNECT'","typeGuard":"def is_connect_line(line):\n    w = line.split()\n    return len(w) in (2,3) and w[0] == b'CONNECT'","tryCatchPattern":null,"preventionTips":["Send well-formed CONNECT request lines","Route non-CONNECT traffic to the plain HTTP path"],"tags":["http-proxy","connect","protocol","parsing"],"backgroundTag":"malformed-http-request","analyzedSha":"cfa5bc17b67676e467f37ec50766127e0ab5f0aa","analyzedAt":"2026-08-27T19:28:28.225Z","schemaVersion":2},"datasetVersion":"2026-08-28T00:17:15.603Z"}