Get status code http.get response angular2

Adding answer for versions of Angular >= 4.3 (including 15) with new HttpClient that replaces http In Angular versions 4.3 and later, the HttpClient module has been introduced, which is an improved version of the old Http module. It allows easier access to HTTP responses, including status code and headers. Here’s an example of how … Read more

Is it OK to return a HTTP 401 for a non existent resource instead of 404 to prevent information disclosure?

Actually, the W3C recommends (RFC 2616 §10.4.4 403 Forbidden) doing the opposite. If someone attempts to access a resource, but is not properly authenticated, return 404 then, rather than 403 (Forbidden). This still solves the information disclosure issue. If the server does not wish to make this information available to the client, the status code … Read more

HTTP status code for unaccepted Content-Type in request

It could be 415 Unsupported Media Type according to this list: http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.4.16. 3rd party edit From the current RFC9110 HTTP Semantics The 415 (Unsupported Media Type) status code indicates that the origin server is refusing to service the request because the content is in a format not supported by this method on the target resource. … Read more

What is the Correct HTTP Status Code for a Cancelled Request

To be consistent I would suggest 400 Bad Request now if your backend apps are capable of identifying when the client gets disconnected or if you reject or close the connection, probably you could return Nginx’ non-standard code 499 or 444. 499 Client Closed Request Used when the client has closed the request before the … Read more