Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

HTTP 302 Redirect - is a message-body needed?

Tags:

RFC 2616 doesn't specify whether a message-body is needed or not, which I interpret as being optional. Is there any practical danger in omitting a message body?

For example, are there bugs (or features) in certain browsers that are triggered by a blank message body in a 302?

like image 804
nicholaides Avatar asked Nov 09 '11 02:11

nicholaides


People also ask

How do I stop 302 redirects?

If the HTTP library which you are using does not enable you to control this behavior, you can set an additional header X-If-No-Redirect with a value of 1 . This will prevent our servers from responding with a 302 status code in the case of a redirect.

Is HTTP 302 a redirect?

The HyperText Transfer Protocol (HTTP) 302 Found redirect status response code indicates that the resource requested has been temporarily moved to the URL given by the Location header.

How does a 302 redirect work?

A 302 redirect does not pass the “juice,” or keep your domain authority to its new location. It simply redirects the user to the new location for you so they don't view a broken link, a 404 not found page, or an error page.


1 Answers

It's not needed. The RFC2616 however doesn't forbid it as well. Note that it does forbid the message body for certain statuses, such as 204 and 304. If the same were true for 302, then it should surely have been explicitly mentioned.

As far as I know, all modern browsers ignore the message body of a 302 in response to a GET or POST and will directly go to the URL as specified in Location header.

like image 126
BalusC Avatar answered Sep 30 '22 07:09

BalusC