diff --git a/crates/relay/src/site.rs b/crates/relay/src/site.rs index f5ee35df29fcc5400350364ae505880d7a36c8b4..11a7a96bd515c5c8b6c845fa845090bbb49125b1 100644 --- a/crates/relay/src/site.rs +++ b/crates/relay/src/site.rs @@ -173,6 +173,9 @@ fn keep_crash( else { return "411 Length Required"; }; + if length == 0 { + return "400 Bad Request"; + } if length > REPORT { return "413 Content Too Large"; } diff --git a/crates/relay/tests/site.rs b/crates/relay/tests/site.rs index f272d101467b3522634d4becf4a86e6e82f9064c..44638b2d2eb3186e815394f435cee833fa9b88dd 100644 --- a/crates/relay/tests/site.rs +++ b/crates/relay/tests/site.rs @@ -170,6 +170,9 @@ fn crash_reports_are_kept_small_and_few_and_never_echoed() { b"POST /crash HTTP/1.1\r\nContent-Type: text/plain\r\nContent-Length: 2\r\n\r\n\xff\xfe", ); assert!(invalid.starts_with("HTTP/1.1 400"), "{invalid}"); + let empty = + site.send(b"POST /crash HTTP/1.1\r\nContent-Type: text/plain\r\nContent-Length: 0\r\n\r\n"); + assert!(empty.starts_with("HTTP/1.1 400"), "{empty}"); // One sender is held to a few an hour; another, by the proxy's word, still gets in. let sent = (0..relay::site::PER_ADDRESS)