Skip to content

Make clientError overridable - #4557

Closed
indutny wants to merge 5 commits into
nodejs:masterfrom
indutny:fix/gh-4543
Closed

Make clientError overridable#4557
indutny wants to merge 5 commits into
nodejs:masterfrom
indutny:fix/gh-4543

Conversation

@indutny

Copy link
Copy Markdown
Member

See: #4543

`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
@indutny

Copy link
Copy Markdown
MemberAuthor

cc @nodejs/http

Comment threaddoc/api/http.markdown Outdated

Copy link
Copy Markdown
Contributor

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."

Copy link
Copy Markdown

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.

Copy link
Copy Markdown
MemberAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ack.

@mscdexmscdex added tls Issues and PRs related to the tls subsystem. http Issues or PRs related to the http subsystem. semver-major PRs that contain breaking changes and should be released in the next major version. labels Jan 6, 2016
@vkurchatkinvkurchatkin removed http Issues or PRs related to the http subsystem. tls Issues and PRs related to the tls subsystem. labels Jan 6, 2016
@mscdexmscdex added tls Issues and PRs related to the tls subsystem. http Issues or PRs related to the http subsystem. labels Jan 6, 2016
@vkurchatkinvkurchatkin added tls Issues and PRs related to the tls subsystem. and removed tls Issues and PRs related to the tls subsystem. labels Jan 6, 2016
@Trott

Trott commented Jan 6, 2016

Copy link
Copy Markdown
Member

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?

@indutny

Copy link
Copy Markdown
MemberAuthor

@Trott yep, I will write a test. Thank you for suggestion

@indutny

Copy link
Copy Markdown
MemberAuthor

@Trott how about this? ;)

@indutny

Copy link
Copy Markdown
MemberAuthor

@mscdex PTAL

@indutny

Copy link
Copy Markdown
MemberAuthor

@mscdex

Copy link
Copy Markdown
Contributor

LGTM if CI is ok with it.

@indutny

Copy link
Copy Markdown
MemberAuthor

Landed in 1ab6b21 and 5f76b24, thank you!

indutny added a commit that referenced this pull request Jan 7, 2016
`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 <mscdex@mscdex.net>
indutny added a commit that referenced this pull request Jan 7, 2016
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 <mscdex@mscdex.net>
@indutnyindutny closed this Jan 7, 2016
@indutny
indutny deleted the fix/gh-4543 branch January 7, 2016 08:39
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

httpIssues or PRs related to the http subsystem.semver-majorPRs that contain breaking changes and should be released in the next major version.tlsIssues and PRs related to the tls subsystem.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants

@indutny@Trott@mscdex@triblondon@vkurchatkin