FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Make `clientError` overridable by indutny · Pull Request #4557 · nodejs/node · GitHub

/ node Public

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 commented Jan 6, 2016

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 commented Jan 6, 2016

Copy link
Copy Markdown
Member Author

cc @nodejs/http

Comment thread doc/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.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

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.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

For people searching the page, mentioning "malformed request" or "invalid HTTP" would be helpful.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Ack.

mscdex 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
vkurchatkin removed http Issues or PRs related to the http subsystem. tls Issues and PRs related to the tls subsystem. labels Jan 6, 2016
mscdex added tls Issues and PRs related to the tls subsystem. http Issues or PRs related to the http subsystem. labels Jan 6, 2016
vkurchatkin 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 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 commented Jan 6, 2016

Copy link
Copy Markdown
Member Author

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

indutny commented Jan 7, 2016

Copy link
Copy Markdown
Member Author

@Trott how about this? ;)

indutny commented Jan 7, 2016

Copy link
Copy Markdown
Member Author

@mscdex PTAL

indutny commented Jan 7, 2016

Copy link
Copy Markdown
Member Author

mscdex commented Jan 7, 2016

Copy link
Copy Markdown
Contributor

LGTM if CI is ok with it.

indutny commented Jan 7, 2016

Copy link
Copy Markdown
Member Author

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>
indutny closed this Jan 7, 2016
indutny deleted the fix/gh-4543 branch January 7, 2016 08:39
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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. tls Issues and PRs related to the tls subsystem.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants


Back | FazBrowse Home | New Git URL