Jump to content

HTTP 302: Difference between revisions

From Wikipedia, the free encyclopedia
Content deleted Content added
Undid revision 585659971 by 177.23.162.82 (talk) Reverting non-English edits.
→‎See also: Added a link to the Permanent Redirect version
Line 22: Line 22:
* [[Hypertext Transfer Protocol]]
* [[Hypertext Transfer Protocol]]
* [[List of HTTP status codes]]
* [[List of HTTP status codes]]
* [[HTTP 301]] - Permanent Redirect


== References ==
== References ==

Revision as of 23:06, 26 February 2014

The HTTP response status code 302 Found is a common way of performing a redirection.

An HTTP response with this status code will additionally provide a URL in the Location header field. The User Agent (e.g. a web browser) is invited by a response with this code to make a second, otherwise identical, request, to the new URL specified in the Location field. The HTTP/1.0 specification (RFC 1945) defines this code, and gives it the description phrase "Moved Temporarily".

Many web browsers implemented this code in a manner that violated this standard, changing the request type of the new request to GET, regardless of the type employed in the original request (e.g. POST).[1] For this reason, HTTP/1.1 (RFC 2616) added the new status codes 303 and 307 to disambiguate between the two behaviours, with 303 mandating the change of request type to GET, and 307 preserving the request type as originally sent. Despite the greater clarity provided by this disambiguation, the 302 code is still employed in web frameworks to preserve compatibility with browsers that do not implement the HTTP/1.1 specification.[2]

Example

Client request:

GET /index.html HTTP/1.1
Host: www.example.com

Server response:

HTTP/1.1 302 Found
Location: http://www.iana.org/domains/example/

See also

References

  1. ^ Lawrence, Eric. "HTTP Methods and Redirect Status Codes". EricLaw's IEInternals blog. Retrieved 20 August 2011.
  2. ^ https://docs.djangoproject.com/en/dev/ref/request-response/#django.http.HttpResponseRedirect
  • RFC 2616 (HTTP 1.1)
  • RFC 1945 (HTTP 1.0)