Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it acceptable to modify the text sent with the HTTP status code?

I'm implementing a 'testing mode' with my website which will forbid access to certain pages while they are undergoing construction, making them only accessible to administrators for private testing. I was planning on using the 401 status code, since the page does exist but they are not allowed to use it, and they may or may not be authenticated, yet only certain users (basically me) would still be allowed to access the page.

The thing I'm wondering is if the text after the HTTP/1.1 401 part mattered? Does it have to be Unauthorized or can it basically be whatever you want to put after it, so long as the 401 is still appropriate for the error? I wanted to send a message such as Temporarily Unavailable to indicate that the page is normally available to all visitors, but is undergoing reconstruction and is temporarily unavailable. Should I do this or not?

like image 648
animuson Avatar asked Nov 12 '11 02:11

animuson


People also ask

What is HTTP status code accepted?

The HyperText Transfer Protocol (HTTP) 202 Accepted response status code indicates that the request has been accepted for processing, but the processing has not been completed; in fact, processing may not have started yet.

What is illegal HTTP status in response?

SecureSphere has detected an HTTP response that does not include a valid HTTP response code. According to the HTTP standard, each HTTP response must contain a 3 digit response code, followed by a string describing its meaning (common examples are ”200 OK” or ”404 Not Found”).

Can I use custom HTTP status codes?

Yes, as long as you respect the class -- that is, 2xx for success, 4xx for Client error, etc. So you can return custom 4XX error codes (preferably those that are unassigned) for your own application's error conditions.

Which is the correct option about the status of the HTTP response?

Which of the following statements are correct about the status of the Http response. 200 to 299 is successful msg. That is the right answer.


1 Answers

You may change them.

The status messages (technically called "reason phrases") are only recommendations and "MAY be changed without affecting the protocol)."

See http://www.w3.org/Protocols/rfc2616/rfc2616-sec6.html#sec6.1.1

However, you SHOULD :-) still use the codes properly and give meaningful messages. Only use a 401 if your condition is what the RFC says a 401 should be.

like image 150
Ray Toal Avatar answered Sep 16 '22 18:09

Ray Toal