hyperium / h2

HTTP 2.0 client & server implementation for Rust.
MIT License
1.34k stars 269 forks source link

Not to consume buf when decoding non_huff header name(which consumes the buf) succeeded but header value failed (DecoderError::NeedMore) #589

Closed hikaricai closed 2 years ago

hikaricai commented 2 years ago

Decoding error when processing continuation frames

hikaricai commented 2 years ago

Anyone?

olix0r commented 2 years ago

@hikaricai it would probably be easier to review this if we had a test that failed without this change.

At a quick glance, this is going to incur an additional (unnecessary?) allocation on each call.

hikaricai commented 2 years ago

@olix0r thanks, I will write a test case.

It seems that the "fn consum" is used only if the decoding is success, but the "fn decode_string" may only be part of decoding. For example, decoding both header name and header value.

I met decoding failure when receiving continuation header which just spilt header name and header value.

hikaricai commented 2 years ago

I have just updated the commit, could anyone helps to review?

olix0r commented 2 years ago

Not sure if @carllerche has bandwidth to review, but I think he knows this code best. Also I think @seanmonstar and @nox have worked on this module ~recently. If no one's available, I'll try to take a look at this but it will take me some time to load up context.

hikaricai commented 2 years ago

Could anyone helps to review? I need this patch to fix bug in my project.

seanmonstar commented 2 years ago

Sorry about that, I'll take a look now.

hikaricai commented 2 years ago

@seanmonstar Is the new commit clearly enough?

The error situation is shown in the new test case