Skip to content

Response with multiple Transfer-Encoding: chunked header fields not parsed as chunk #683

Closed
@nham

Description

@nham

I've adapted this code from client/response.rs:

fn main() {
    let stream = MockStream::with_input(b"\
        HTTP/1.1 200 OK\r\n\
        Transfer-Encoding: chunked\r\n\
        Transfer-Encoding: chunked\r\n\
        \r\n\
        1\r\n\
        q\r\n\
        2\r\n\
        we\r\n\
        2\r\n\
        rt\r\n\
        0\r\n\
        \r\n"
    );

    let url = Url::parse("http://hyper.rs").unwrap();
    let mut res = Response::new(url, Box::new(stream)).unwrap();

    let mut s = String::new();
    res.read_to_string(&mut s).unwrap();
    println!("{:?}", s);
}

The result is:

"1\r\nq\r\n2\r\nwe\r\n2\r\nrt\r\n0\r\n\r\n"

Unless I'm misreading the HTTP spec, it seems

HTTP/1.1 200 OK\r\n
Transfer-Encoding: chunked\r\n
Transfer-Encoding: chunked\r\n

should be the same as

HTTP/1.1 200 OK\r\n
Transfer-Encoding: chunked, chunked\r\n

The latter correctly results in "qwert" being printed out.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-headersArea: headers.C-bugCategory: bug. Something is wrong. This is bad!

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions