Jump to content

HTTP 303: Difference between revisions

From Wikipedia, the free encyclopedia
Content deleted Content added
m Changed "Restful" to "RESTful" and removed a biof indirection in the link.
→‎Example: remove this awful example (which results in blanking this whole section)
 
(43 intermediate revisions by 38 users not shown)
Line 1: Line 1:
{{Short description|HTTP response status code}}
{{HTTP}}
{{HTTP}}
The [[HTTP]] response [[List of HTTP status codes|status code]] '''303 See Other''' is the correct way to redirect web applications to a new [[Universal_Resource_Identifier|URI]], particularly after an [[HTTP POST]] has been performed.
The [[HTTP]] response [[List of HTTP status codes|status code]] '''303 See Other''' is a way to redirect web applications to a new [[uniform resource identifier|URI]], particularly after a [[HTTP POST]] has been performed, since RFC 2616 (HTTP 1.1).


According to RFC 7231, which obsoletes RFC 2616, "A 303 response to a GET request indicates that the origin server does not have a representation of the target resource that can be transferred by the server over HTTP. However, the Location field value refers to a resource that is descriptive of the target resource, such that making a retrieval request on that other resource might result in a representation that is useful to recipients without implying that it represents the original target resource."
This response indicates that the correct response can be found under a different URI and should be retrieved using a GET method. The specified URI is not a substitute reference for the original resource.


This status code should be used with the [[HTTP location|location]] header, as described below.
This status code should be used with the [[HTTP location|location]] header, as described below. If a server responds to a POST or other non-idempotent request with a ''303 See Other'' response and a value for the location header, the client is expected to obtain the resource mentioned in the location header using the GET method; to trigger a request to the target resource using the same method, the server is expected to provide a ''307 Temporary Redirect'' response.


'''303 See Other''' has been proposed as one way of responding to a request for a [[Universal_Resource_Identifier|URI]] that identifies a ''real-world object'' according to [[Semantic Web]] theory (the other being the use of ''hash URIs'').<ref>[http://www.w3.org/TR/cooluris/ Cool URIs for the Semantic Web], see section 4</ref> For example, when building a [[Representational_state_transfer|RESTful web service]] that needs to return to the caller immediately but continue executing asynchronously (such as a long-lived image conversion), the web service can provide a status check URI that allows the original client who requested the conversion to check on the conversion's status. This status check web service should return '''303 See Other''' to the caller when the task is complete, along with a URI from which to retrieve the result in the ''Location'' [[HTTP header]] field.<ref>Subbu Allamaraju. ''RESTful Web Services Cookbook: Solutions for Improving Scalability and Simplicity''. O'Reilly Media, 2010, p. 20.</ref>
'''303 See Other''' has been proposed as one way of responding to a request for a [[uniform resource identifier|URI]] that identifies a ''real-world object'' according to [[Semantic Web]] theory (the other being the use of ''hash URIs'').<ref>{{cite web|url=https://www.w3.org/TR/cooluris/#hashuri|title=Cool URIs for the Semantic Web: Hash URIs|work=W3C Interest Group Note|date=2008-12-03}}</ref> For example, if <code><nowiki>http://www.example.com/id/alice</nowiki>{{Cbignore}}</code> identifies a person, Alice, then it would be inappropriate for a server to respond to a GET request with 200 OK, as the server could not deliver Alice herself. Instead the server would issue a 303 See Other response which redirected to a separate URI providing a description of the person Alice.


'''303 See Other''' can be used for other purposes. For example, when building an HTTP-based [[web API]] that needs to respond to the caller immediately but continue executing asynchronously (such as a long-lived image conversion), the web API can provide a status check URI that allows the original client who requested the conversion to check on the conversion's status. This status check web API might itself return '''303 See Other''' to the requestor when the task has completed, with a link to a URI from which to retrieve the result in the [[HTTP location|''Location'']] [[HTTP header]] field.<ref>{{cite book|title=RESTful Web Services Cookbook|first1=Subbu|last1=Allamaraju|first2=Subrahmanyam|last2=Allamaraju|date=March 2010|publisher=[[O'Reilly Media]]|isbn=9780596801687}}</ref>
==Example==
Client request:
<pre>
GET / HTTP/1.1
Host: www.example.com
</pre>
Server response:
<pre>
HTTP/1.1 303 See Other
Location: http://example.org/other
</pre>


==See also==
==See also==
* RFC 2616 (HTTP 1.1)
* [https://www.rfc-editor.org/rfc/rfc1945 RFC 1945] (HTTP 1.0)
* RFC 1945 (HTTP 1.0)
* [https://www.rfc-editor.org/rfc/rfc7231 RFC 7231] (HTTP 1.1)
* [[Hypertext Transfer Protocol]]
* [[Hypertext Transfer Protocol]]
* [[List of HTTP status codes]]
* [[List of HTTP status codes]]
* [[Post/Redirect/Get]]
* [[Post/Redirect/Get]]
* [[HTTP 301]] (Permanent redirect)


==References==
==References==
{{reflist}}
{{reflist}}


[[Category:HTTP status codes]]
[[Category:Hypertext Transfer Protocol status codes]]
[[Category:Article Feedback 5]]



{{web-stub}}
{{web-stub}}

[[id:HTTP 303]]
[[pt:HTTP 303]]

Latest revision as of 20:54, 22 September 2023

The HTTP response status code 303 See Other is a way to redirect web applications to a new URI, particularly after a HTTP POST has been performed, since RFC 2616 (HTTP 1.1).

According to RFC 7231, which obsoletes RFC 2616, "A 303 response to a GET request indicates that the origin server does not have a representation of the target resource that can be transferred by the server over HTTP. However, the Location field value refers to a resource that is descriptive of the target resource, such that making a retrieval request on that other resource might result in a representation that is useful to recipients without implying that it represents the original target resource."

This status code should be used with the location header, as described below. If a server responds to a POST or other non-idempotent request with a 303 See Other response and a value for the location header, the client is expected to obtain the resource mentioned in the location header using the GET method; to trigger a request to the target resource using the same method, the server is expected to provide a 307 Temporary Redirect response.

303 See Other has been proposed as one way of responding to a request for a URI that identifies a real-world object according to Semantic Web theory (the other being the use of hash URIs).[1] For example, if http://www.example.com/id/alice identifies a person, Alice, then it would be inappropriate for a server to respond to a GET request with 200 OK, as the server could not deliver Alice herself. Instead the server would issue a 303 See Other response which redirected to a separate URI providing a description of the person Alice.

303 See Other can be used for other purposes. For example, when building an HTTP-based web API that needs to respond to the caller immediately but continue executing asynchronously (such as a long-lived image conversion), the web API can provide a status check URI that allows the original client who requested the conversion to check on the conversion's status. This status check web API might itself return 303 See Other to the requestor when the task has completed, with a link to a URI from which to retrieve the result in the Location HTTP header field.[2]

See also[edit]

References[edit]

  1. ^ "Cool URIs for the Semantic Web: Hash URIs". W3C Interest Group Note. 2008-12-03.
  2. ^ Allamaraju, Subbu; Allamaraju, Subrahmanyam (March 2010). RESTful Web Services Cookbook. O'Reilly Media. ISBN 9780596801687.