-
Notifications
You must be signed in to change notification settings - Fork 29.8k
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
Make clientError
overridable
#4557
Conversation
`clientError` will have `http.Server`-specific behavior, and we don't want to shadow it in `tls.Server`.
Make default `clientError` behavior (close socket immediately) overridable. With this APIs it is possible to write a custom error handler, and to send, for example, a 400 HTTP response. http.createServer(...).on('clientError', function(err, socket) { socket.end('HTTP/1.1 400 Bad Request\r\n\r\n'); socket.destroy(); }); Fix: nodejs#4543
cc @nodejs/http |
Listener of this event is responsible for destroying socket, and, for example, | ||
can do it it gracefully by sending 400 HTTP response. | ||
|
||
Default behavior is destroy socket immediately. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perhaps: "Default behavior is to destroy the socket immediately."
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For people searching the page, mentioning "malformed request" or "invalid HTTP" would be helpful.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ack.
Should there be a test that triggers clientError with and without the override to confirm both more-or-less basically work as expected? Or is the idea that the modified TLS tests already check the override and other existing tests already check the basic behavior? |
@Trott yep, I will write a test. Thank you for suggestion |
@Trott how about this? ;) |
@mscdex PTAL |
LGTM if CI is ok with it. |
`clientError` will have `http.Server`-specific behavior, and we don't want to shadow it in `tls.Server`. PR-URL: #4557 Reviewed-By: Brian White <[email protected]>
Make default `clientError` behavior (close socket immediately) overridable. With this APIs it is possible to write a custom error handler, and to send, for example, a 400 HTTP response. http.createServer(...).on('clientError', function(err, socket) { socket.end('HTTP/1.1 400 Bad Request\r\n\r\n'); socket.destroy(); }); Fix: #4543 PR-URL: #4557 Reviewed-By: Brian White <[email protected]>
See: #4543