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
HttpErrorResponse statusText always default to 'OK' regardless of statusCode #23334
Comments
It's NOT caused by Angular, but a XHR spec defined behavior. It would still be |
Oh, I didn't though it could have been something from the XHR spec, thanks @trotyl for letting me know! I slightly modified the doc to add the default value then (as the original documentation actually), in case someone else encounters the same "issue". |
Closing as @trotyl is correct, it's specified behavior. |
The XHR spec cited by @trotyl no longer defines
This issue should be reopened. When the response has an empty status message Angular should leave it that way instead of setting it to |
Confirmed, the spec change was made at whatwg/fetch#600. |
Any update on this issue, should it be reopened? |
FWIW If you're using the angular-cli proxy, it will add the correct statusText. We discovered this because for local development we use the proxy to forward to our deployed backend service. 4xx responses always had the right text. But once we deployed the same code, the response statusText was always 'OK'. Confirmed this to be true by bypassing the proxy.conf.json on a locally running UI. Just provide the direct URL for one of the http requests. |
Yep, we should change to an empty string I suppose. It'll require a little thought to ensure this can happen without breaking existing consumers. |
FYI: The HTTP/2 spec removed this "statusText" ("reason phrase"). So if you add an HTTP/2 proxy or load ballancer in between your HTTP/1.1 API and your Angular application, you will encounter the default
|
@jovanarsov Is there any update about issue? Im having same problem in my App. |
|
@jovanarsov Thank you for the answer! |
The error status text shows: 'OK'. It should be showing 'Bad Request' in case of 400 and 'Unauthorized' in case of 401. This happens because of http/2 spec and the way the Angular client defaults to displaying an OK if there is nothing in the statusText field as described here: angular/angular#23334
@jovanarsov Thanks |
I'm submitting a...
Current behavior
When server response does not contain any statusText, HttpErrorResponse.statusText is automatically set to
OK
regardless of the status code.Thus you can end up with
403 OK
error response for instance, which I believe is weird. In the previous documentation it was clearly stated thatOK
was the default value, but I'm not sure to understand the reason behind it -- an empty string would be less confusing I think.Expected behavior
Either the statusString should be left empty, or even better check for status code and either use the proper http status for it, or show
ok
only for success status code only (and.. something has to be done for others)?Minimal reproduction of the problem with instructions
What is the motivation / use case for changing the behavior?
While debugging some 403 errors on a website, I looked at HttpErrorResponse object with a 403 OK status which made me think there was something going wrong with the server and/or the error handling, but actually that was not the error at all. I know that documentation states
Do not depend on this.
, but this is still misleading when you see that in logs IMO.Environment
The text was updated successfully, but these errors were encountered: