seanmonstar / httparse

A push parser for the HTTP 1.x protocol in Rust.
https://docs.rs/httparse
Apache License 2.0
590 stars 115 forks source link

Weird header parsing in 1.9 #172

Closed Tpt closed 5 months ago

Tpt commented 5 months ago

Thank you so much for httparse all your other amazing libraries.

Sorry for the maybe bad bug report, I am not a HTTP expert.

With the new 1.9 version I get a test regression in oxhttp with strange parsing result. A : gets included in one of the header value.

Here is a test to reproduce the possible regression:

    #[test]
    fn test_http_parse() {
        let mut headers = [httparse::EMPTY_HEADER; 1024];
        let mut parsed_request = httparse::Request::new(&mut headers);
        parsed_request
            .parse(b"POST / HTTP/1.1\ncontent-length:4\n\n")
            .unwrap();
        for header in parsed_request.headers {
            if header.name == "content-length" {
                assert_eq!(header.value, b"4"); // Fails, we get ':4'
            }
        }
    }

Thank you again for your library.

seanmonstar commented 5 months ago

Thanks for the report, PR at #174.

Tpt commented 5 months ago

Thank you!