hyper
hyper copied to clipboard
HTTP/2 should send a reset of NO_ERROR instead of CANCEL if already sent response headers
I write a proxy service that use hyper.I upload a file by chrome browser use http2 to my proxy service.In my proxy service,i check the file size by request header content-length and find it is too large, i retrun response with status code 413 without reading the request body immediately.chrome report ERR_HTTP2_PROTOCOL_ERROR, but it is ok in http1.1. I read http2.0 protocol rfc7540 and find program should send RST_STREAM frame with an error code of NO ERROR after sending a complete response. Does hyper provide a solution to this problem?How to solve the problem?
hyper does send a reset frame after you've responded and dropped the request body without reading.
The error seems to suggest it's related to SSL, not to HTTP/2.
@seanmonstar thank you. i don't think it is related to SSL. It it performance well in http1.1;if i read the request body,it performance well in http2.0,too. Does hyper send a reset frame with an error code of NO ERROR already?in which version?i don‘t see this code by searching keyword send_reset?I only find send_reset(h2::Reason::INTERNAL_ERROR)
The automatic sending of a reset is handled in h2, a dependency of hyper.
@seanmonstar chrome report ERR_HTTP2_PROTOCOL_ERROR ,not ERR_SSL_PROTOCOL_ERROR ,i wrote error last time
Does this happen with other clients? Firefox? curl? Some other language client?
@seanmonstar yes,i try chrome,firefox,Microsoft Edge,all report ERR_HTTP2_PROTOCOL_ERROR
@seanmonstar if i read all request body, then response status code 413, it is ok. if i response status code 413 without reading request body, it is not ok.I think hyper should send RST_STREAM frame with error code of NO ERROR after respone status code 413 without waiting for all request body.
@seanmonstar i open hyper trace log,hyper send reset frame with error_code CANCEL. FramedWrite::buffer[0m[1m{[0mframe=Reset { stream_id: StreamId(647), error_code: CANCEL
Ah, I see. So currently, if you drop all handles to the stream while there is still things to read, it will automatically send a reset of CANCEL. The h2 library should be updated to check if (a) we are the server, and (b) if response headers have already been sent, then change to sending a reset of NO_ERROR instead.
@seanmonstar do you have a plan to fix this issue?
I have not prioritized fixing this myself, but we welcome contributions if you'd like to join in, or anyone else :)
I believe this issue was fixed in https://github.com/hyperium/h2/pull/634
Ah yes!