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
Allow non-standard http status codes to be used #1042
Comments
Last option, which I would prefer, is not to expose an API for handling statuses but rather to expose the validation fn, which can be overloaded/replaced as needed. |
what about passing your own version of this will need some way of subclassing |
how about removing the dependency, and people can add it as a middleware if needed ( in good Koa spirit ) |
@jonathanong if your solution is the approach you'd favour, it would (to my understanding) require:
For which the end result for Koa developer would become something pseudo alike: const app = new Koa()
const statuses = require('statuses')
statuses.mergeStatusesMap({
440: 'invalid chicken'
})
app.statuses = statuses Did I follow you correctly here? |
@fl0w @jonathanong Is this still needed? EDIT: Modify |
What about just validating that the status code is a number as per the HTTP spec?
|
Another use-case for this is Cloudflare using its own set of non-RFC status codes - https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#Cloudflare |
No, that's gross :) honestly, i would just add my custom status codes to |
Hi, As mentionned by @fl0w, here I'm currently developing an app which needs the usage of the non-standard code 449 introduced by Microsoft. Maybe we need to discuss about introducing non-standard codes |
I'm working on it. |
Hey this has been more than a year now. We're hacking our way to achieve this, I've just checked the PR what's missing from it? |
actually I'd like to only check the status code is a three-digit integer, there is no need to prevent developers using custom statuses which RFC allowed:
|
closes via #1308 |
Koa throws when a status code not defined in the
statuses
package is used in response:koa/lib/response.js
Line 84 in 78832ff
However, the HTTP RFC does not prevent custom status codes to be used:
http://greenbytes.de/tech/webdav/draft-ietf-httpbis-p2-semantics-25.html#rfc.section.6.p.2
I can understand why status code validation might be useful for people just starting with http protocols, but for people who actually need to use custom codes, this is very limiting.
Proposal
There are several options that the Koa team could choose to remediate the problem:
koa.validateStatus = false
)koa.AddStatus(440, 'Invalid Chicken')
)I personally like the second and third approach. Currently the third approach is possible, albeit in a hacky way:
The text was updated successfully, but these errors were encountered: