{"record":{"id":"dc613917d366d1e6","repo":"affaan-m/ECC","slug":"missing-http-request-line","errorCode":null,"errorMessage":"Missing HTTP request line","messagePattern":"Missing HTTP request line","errorType":"validation","errorClass":"anyhow::Error","httpStatus":null,"severity":"warning","filePath":"ecc2/src/main.rs","lineNumber":4215,"sourceCode":"        if read == 0 {\n            anyhow::bail!(\"Unexpected EOF while reading HTTP request\");\n        }\n        buffer.extend_from_slice(&temp[..read]);\n        if let Some(index) = buffer.windows(4).position(|window| window == b\"\\r\\n\\r\\n\") {\n            break index + 4;\n        }\n        if buffer.len() > 64 * 1024 {\n            anyhow::bail!(\"HTTP request headers too large\");\n        }\n    };\n\n    let header_text = String::from_utf8(buffer[..header_end].to_vec())\n        .context(\"HTTP request headers were not valid UTF-8\")?;\n    let mut lines = header_text.split(\"\\r\\n\");\n    let request_line = lines\n        .next()\n        .filter(|line| !line.trim().is_empty())\n        .ok_or_else(|| anyhow::anyhow!(\"Missing HTTP request line\"))?;\n    let mut request_parts = request_line.split_whitespace();\n    let method = request_parts\n        .next()\n        .ok_or_else(|| anyhow::anyhow!(\"Missing HTTP method\"))?\n        .to_string();\n    let path = request_parts\n        .next()\n        .ok_or_else(|| anyhow::anyhow!(\"Missing HTTP path\"))?\n        .to_string();\n\n    let mut headers = BTreeMap::new();\n    for line in lines {\n        if line.is_empty() {\n            break;\n        }\n        if let Some((key, value)) = line.split_once(':') {\n            headers.insert(key.trim().to_ascii_lowercase(), value.trim().to_string());\n        }","sourceCodeStart":4197,"sourceCodeEnd":4233,"githubUrl":"https://github.com/affaan-m/ECC/blob/8321021c54d670126ce3b2969d5deb880b4b0c2a/ecc2/src/main.rs#L4197-L4233","documentation":"This error comes from the local HTTP request parser (used by an embedded/dev server in main.rs). After locating the header terminator `\\r\\n\\r\\n`, the parser splits the header text into lines and requires the first line to be a non-empty request line. A connection whose first header line is missing or blank yields this error.","triggerScenarios":"A client opens a TCP connection and sends an empty payload or only `\\r\\n`; the buffer read returns a header_end of 0 with an empty header region; malformed/binary data where no valid first line exists; health-check probes that connect and immediately close.","commonSituations":"Load balancers or monitoring tools opening raw TCP connections without sending a request; a client speaking the wrong protocol (e.g. TLS bytes to a plain-HTTP port, or HTTP/2 preface not handled); half-written requests due to network truncation.","solutions":["Send a well-formed HTTP/1.x request starting with a request line like `GET /path HTTP/1.1` followed by CRLF.","Check that you're not connecting with TLS/HTTPS to a plain-HTTP port (or vice versa).","Inspect the client (curl, browser, health checker) to ensure it actually writes a request before closing.","If this is a health probe, switch it to an actual HTTP GET rather than a bare TCP connect."],"exampleFix":"// before (raw TCP probe, no request sent)\n$ printf '' | nc localhost 8080\n// after\n$ curl -v http://localhost:8080/healthz","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"// Client side: ensure a full request is written before shutdown\nconn.write_all(b\"GET /healthz HTTP/1.1\\r\\nHost: localhost\\r\\nConnection: close\\r\\n\\r\\n\")?;\nconn.flush()?;","preventionTips":["Use real HTTP clients (curl, reqwest) against the server instead of raw TCP probes.","Don't point TLS clients at plain-HTTP ports.","Configure health checks to send an actual HTTP GET, not a bare connect."],"tags":["http","network","parsing","malformed-request"],"backgroundTag":"invalid-argument-format","analyzedSha":"8321021c54d670126ce3b2969d5deb880b4b0c2a","analyzedAt":"2026-09-16T10:08:13.343Z","contentChangedAt":"2026-09-16T10:08:13.343Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}