hyperium / http-body

Asynchronous HTTP body trait
MIT License
129 stars 50 forks source link

Empty frame cause panic #88

Closed chrislearn closed 1 year ago

chrislearn commented 1 year ago

https://github.com/hyperium/http-body/blob/619ba28c5699c8f47608c31c56a30a488fae769d/http-body-util/src/collected.rs#L44 https://github.com/hyperium/http-body/blob/619ba28c5699c8f47608c31c56a30a488fae769d/http-body-util/src/util.rs#L14

When frame is empty, this cause panic, just wondering if this is expected behavior? Some HTTP/2 implementations may product empty frames, when I create a reverse proxy server,and call body.collect().await.to_bytes() to read data, server will give error in debug mode. Or just give a warning here?

seanmonstar commented 1 year ago

The collect combinator should probably filter out the empty data frames, to prevent the panic.

chrislearn commented 1 year ago

https://github.com/hyperium/http-body/blob/619ba28c5699c8f47608c31c56a30a488fae769d/http-body-util/src/collected.rs#L41-L48

In push_frame, just push data to bufs and does not check is data is empty.

https://github.com/hyperium/http-body/blob/619ba28c5699c8f47608c31c56a30a488fae769d/http-body-util/src/combinators/collect.rs#L25-L43

In Collect's poll function, call push_frame directly and push the frame.

meowjesty commented 1 year ago

Hi what's the status on this? Anyone working on adding this change?

Had to make this change for our project, can send a PR if no one is working on this.

davidpdrsn commented 1 year ago

No I don't think anyone is working on it. You're welcome to submit a PR.

aviramha commented 1 year ago

Hey, we'd love to use an officially released version. Is it possible to please create a release? @seanmonstar