Skip to content
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

feat(http): allow custom http codes along with custom response text #855

Merged
merged 4 commits into from
May 11, 2021
Merged

feat(http): allow custom http codes along with custom response text #855

merged 4 commits into from
May 11, 2021

Conversation

lowlighter
Copy link
Contributor

@lowlighter lowlighter commented Apr 14, 2021

Closes #664

As specified in the rfc2616 spec:

HTTP status codes are extensible. HTTP applications are not required to understand the meaning of all registered status codes, though such understanding is obviously desirable. However, applications MUST understand the class of any status code, as indicated by the first digit, and treat any unrecognized response as being equivalent to the x00 status code of that class, with the exception that an unrecognized response MUST NOT be cached. For example, if an unrecognized status code of 431 is received by the client, it can safely assume that there was something wrong with its request and treat the response as if it had received a 400 status code. In such cases, user agents SHOULD present to the user the entity returned with the response, since that entity is likely to include human- readable information which will explain the unusual status.

Since this PR allows custom codes which may have not default response text defined, this also add statusText so custom error codes can be sent with human readable messages.

http/_io.ts Outdated Show resolved Hide resolved
@alexanderGalushka
Copy link

@bartlomieju can you please look at this PR

@bartlomieju bartlomieju requested review from kt3k and wperron May 10, 2021 20:56
Copy link
Member

@kt3k kt3k left a comment

Choose a reason for hiding this comment

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

LGTM

@kt3k kt3k merged commit 1b4eff0 into denoland:main May 11, 2021
@lowlighter lowlighter deleted the feat-http-allow-custom-error-codes branch May 11, 2021 11:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[bug]: allow custom http codes
4 participants