affaan-m/ECC · warning · anyhow::Error
Missing HTTP request line
Error message
Missing HTTP request line
What it means
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.
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.
Example fix
// before (raw TCP probe, no request sent) $ printf '' | nc localhost 8080 // after $ curl -v http://localhost:8080/healthz
Defensive patterns
Strategy: try-catch
Try / catch
// Client side: ensure a full request is written before shutdown conn.write_all(b"GET /healthz HTTP/1.1\r\nHost: localhost\r\nConnection: close\r\n\r\n")?; conn.flush()?;
Prevention
- 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.
When it happens
Trigger: 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.
Common situations: 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.
Understand the failure class
Background: "Invalid ... format", "must be in format X", "does not look like a ..." — invalid argument format errors across CLI tools and libraries — this error's family across 17 libraries.
Related errors
- Missing HTTP method
- Control-plane request failed
- download declares an invalid or excessive size
- download exceeds maximum allowed size
- download length does not match declared size
AI-assisted analysis of affaan-m/ECC@8321021c54 (2026-09-16).
Data as JSON: /api/errors/dc613917d366d1e6.
Report an issue: GitHub.
Appendix: source
Thrown at ecc2/src/main.rs:4215
if read == 0 {
anyhow::bail!("Unexpected EOF while reading HTTP request");
}
buffer.extend_from_slice(&temp[..read]);
if let Some(index) = buffer.windows(4).position(|window| window == b"\r\n\r\n") {
break index + 4;
}
if buffer.len() > 64 * 1024 {
anyhow::bail!("HTTP request headers too large");
}
};
let header_text = String::from_utf8(buffer[..header_end].to_vec())
.context("HTTP request headers were not valid UTF-8")?;
let mut lines = header_text.split("\r\n");
let request_line = lines
.next()
.filter(|line| !line.trim().is_empty())
.ok_or_else(|| anyhow::anyhow!("Missing HTTP request line"))?;
let mut request_parts = request_line.split_whitespace();
let method = request_parts
.next()
.ok_or_else(|| anyhow::anyhow!("Missing HTTP method"))?
.to_string();
let path = request_parts
.next()
.ok_or_else(|| anyhow::anyhow!("Missing HTTP path"))?
.to_string();
let mut headers = BTreeMap::new();
for line in lines {
if line.is_empty() {
break;
}
if let Some((key, value)) = line.split_once(':') {
headers.insert(key.trim().to_ascii_lowercase(), value.trim().to_string());
}View on GitHub (pinned to 8321021c54)