mini-static 0.20.0

A secure, async static file server with streaming, traversal protection, and connection limits.
Documentation
use super::*;

// Disproves a bare `.unwrap()` on the same builder: CR/LF is not a legal header
// value byte (it would enable header/response splitting), so this construction is
// guaranteed to make `.body(...)` return `Err`. Every real call site in this module
// only ever builds header values from static strings or internally-formatted
// numbers, so this test can't happen through normal use — it exists to prove
// `finish()`'s fallback path actually works, not to exercise a reachable case.
#[test]
fn finish_degrades_to_400_on_invalid_header_value_instead_of_panicking() {
    let built = Response::builder()
        .status(StatusCode::OK)
        .header("X-Test", "invalid\r\nvalue")
        .body(ResponseBody::Buffered(Full::new(Bytes::new())));
    assert!(
        built.is_err(),
        "CR/LF in a header value should be rejected by the builder"
    );

    let response = finish(built);
    assert_eq!(
        response.status(),
        StatusCode::BAD_REQUEST,
        "finish() should degrade to 400 rather than panicking on an invalid header value"
    );
}