-
Notifications
You must be signed in to change notification settings - Fork 299
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
Support custom status code #144
Comments
A status code of 6xx violates the HTTP spec. Do you have an example of another server returning 6xx? |
I know that neither HTTP spec nor IANA defines the status code greater than 599. As I mentioned above, some RESTful service may use UNREGISTERED status codes. The following is an example which uses
Not support custom status codes and response phrase will stumble those want to migrate to rust. |
New status codes are required to fall under one of the categories defined
in Section 6 <https://tools.ietf.org/html/rfc7231#section-6>.
|
I think there are no conflict. curl, openresty, wireshark ... and so on, can parse the undefined status code and response phrase, why |
By sticking with the spec, the http crate is able to make performance optimizations. Violating the spec in this way would make the crate slower for those who follown then spec. The argument to make the library slower for everyone would need to be very compelling. |
Can we provide a feature gate for it? |
@quininer can you provide the use case? |
@carllerche I have an interface that returns 9xx, and I hate it, but that's the realworld. :( |
@carllerche there are many services in |
https://tools.ietf.org/html/rfc7230#section-3.1.2:
https://tools.ietf.org/html/rfc7231#section-6:
https://tools.ietf.org/html/rfc7231#section-8.2.2 is only relevant if I want to register my status code to IANA, because https://tools.ietf.org/html/rfc7231#section-8 is "IANA Considerations" A response with 3-digit status code >= 600 is syntactically(rfc7230) valid. This library, ideally, should leave the interpretation of the semantics(rfc7231) of a HTTP response to the code that uses it, especially since this library doesn't try to enforce most of the semantics rules defined in rfc7231. |
linkedin profiles return |
Also, considering that there is an ongoing work on PoC for integration with curl (which handles such codes without an issue), it makes sense to support what all the major UAs support. In addition, as was pointed above, such codes don't violate RFC7231. |
As an additional argument, this crate supports arbitrary HTTP methods to which similar IANA considerations apply - https://tools.ietf.org/html/rfc7231#section-8.1. So, the spec argument is at least inconsistent. |
Can this be given a second look? It indeed doesn't seem reasonable to restrict the range like this when the existing range is really just IANA specific and not binding on implementations, as long as they meet the syntax requirement and minimum semantic requirements. |
In case anyone is interested, I've been using My own fork as a short term solution eaufavor@fb16fac.
|
To try an give some more perspective on this, note that all of the following broadly used reverse proxy servers currently support status codes 100-999: On one hand, it seems reasonable enough for a new server, like linkerd, to reject status codes >599. But particularly when the |
Currently, hyper and this crate only support status code from
[100, 600)
, otherwise will cause errorInvalidStatusCode
, which make parse aResponse
with custom code failed eventually.For example:
will cause
But, sometime, some service will define custom status code, especially in some RESTful API.
So, I think it is fine to support custom code and reason.
The text was updated successfully, but these errors were encountered: