-
Notifications
You must be signed in to change notification settings - Fork 30.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
http: abort tcp connection in the middle of request handling #8775
Comments
@pps83, looks like your issue may be related to #8102. |
@nodejs/http @nodejs/platform-windows Is there anything to do on the Node.js side on this one? Any helpful information to provide @pps83? Should this remain open? |
Just taking the opportunity to ask a question: is it possible to make the server send |
ping @nodejs/http @nodejs/http2 |
I think we can close this one. By design our client does not validate that the body size matches the given content-length. It's clearly written in the docs:
No, libuv does not support this. My guess is that would be very hard to support in a cross-platform manner. |
What is a proper api to abort http reply in the middle? Suppose http server started reply, wrote
Content-Length
header and then in the middle of serving body there was some event that made that reply invalid or impossible to complete.res.end()
isn't acceptable if full body wasn't written yet (as it would cause havoc if keep-alive was in effect), so TCP connection has to be closed (and there is no api provided for that?).The problem is that on receiver side there is no 'error' event triggered even though full body wasn't received. It seems that if TCP is aborted with RST then there is an 'error' event triggered (this happens on Win10, but not on ubuntu, however I didn't check if there is actual tcp RST sent on ubuntu).
Is there any api to abort http request so that on client side there would be an 'error' event? The other point: what if chunked transfer encoding was used and server had to abort reply in the middle? on client side 'error' event should be emitted if response finished before handling final
0\r\n\r\n
, otherwise how is the client supposed to know that the body wasn't complete?Shouldn't node check for content-length header and trigger 'error' event if body size doesn't match content length? Same for sender side: shouldn't it trigger exception if response body size doesn't match content-length header? At least this behavior should be configurable perhaps?
Below is a simple example for simplicity: server starts serving reply, says that it's 10-bytes long and then after serving 9 bytes simply closes the connection after 500ms. I wasn't able to find a way to abort http connection on server side so that client gets an error instead of thinking that request was properly served.
and then
On Win10 if I throw exception before ending reply then on client side I do get the 'error' event, however, on ubuntu there is no error events posted.
It seems that there was something related posted a while ago: nodejs/node-v0.x-archive#1776
The text was updated successfully, but these errors were encountered: