{"record":{"id":"a6d045b50d52fcac","repo":"XX-net/XX-Net","slug":"http-req-line-fail-s","errorCode":null,"errorMessage":"http req line fail:%s","messagePattern":"http req line fail:(.+?)","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"code/default/smart_router/local/proxy_handler.py","lineNumber":344,"sourceCode":"\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):\n        req_data = self.conn.recv(65537, socket.MSG_PEEK)\n        rp = req_data.split(b\"\\r\\n\")\n        req_line = rp[0]\n\n        words = req_line.split()\n        if len(words) == 3:\n            method, url, http_version = words\n        elif len(words) == 2:\n            method, url = words\n            http_version = b\"HTTP/1.1\"\n        else:\n            xlog.warn(\"http req line fail:%s\", req_line)\n            return\n\n        if url.lower().startswith(b\"http://\"):\n            o = urlparse(url)\n            host, port = netloc_to_host_port(o.netloc)\n\n            url_prex_len = url[7:].find(b\"/\")\n            if url_prex_len >= 0:\n                url_prex_len += 7\n                path = url[url_prex_len:]\n            else:\n                url_prex_len = len(url)\n                path = b\"/\"\n        else:\n            # not proxy request\n            parsed_url = urlparse(utils.to_str(url))\n            kv = parse_qs(parsed_url.query)\n            if parsed_url.path == \"/dns-query\":","sourceCodeStart":326,"sourceCodeEnd":362,"githubUrl":"https://github.com/XX-net/XX-Net/blob/cfa5bc17b67676e467f37ec50766127e0ab5f0aa/code/default/smart_router/local/proxy_handler.py#L326-L362","documentation":"The plain-HTTP request line did not contain 2 or 3 whitespace-separated tokens, so method/url extraction failed and the request is dropped.","triggerScenarios":"Malformed first line such as 'GET' with no path, binary garbage, or a request missing HTTP version delimiters.","commonSituations":"Health probes or scanners sending non-HTTP bytes, broken clients, encoding corruption, or an HTTPS handshake reaching the HTTP handler.","solutions":["Inspect the logged req_line to see the raw bytes the client sent","Verify the client actually speaks HTTP on this port (not TLS bytes)","Fix client request formatting / add proper CRLF line endings"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"tokens = req_line.split(); assert 2 <= len(tokens) <= 3","typeGuard":"def is_http_request_line(l):\n    t = l.split()\n    return len(t) in (2,3) and t[0].isalpha()","tryCatchPattern":null,"preventionTips":["Never send TLS bytes to a plain HTTP port","Use real HTTP client libraries"],"tags":["http","protocol","parsing","request-line"],"backgroundTag":"malformed-http-request","analyzedSha":"cfa5bc17b67676e467f37ec50766127e0ab5f0aa","analyzedAt":"2026-08-27T19:28:28.225Z","schemaVersion":2},"datasetVersion":"2026-08-28T00:17:15.603Z"}