Read "Schematic http" Summary--fourth Chapter

Source: Internet
Author: User
Tags 303 status code http authentication

HTTP status code to return results

The HTTP status code is responsible for representing the return result of the client HTTP request, marking the server side for normal processing. Notification of errors and other work. Below is the detailed description of the working mechanism of the status code.


4.1 Status code tells the result of requests returned from the server side

The responsibility of the status code is to describe the result of the request that is returned when the client sends a request to the server side. With the status code, the user can know whether the server side is handling the request properly or if there is a problem.

status codes such as 3 digits and a reason phrase. The first bit in the number specifies the response type, and the latter two bits are not categorized. There are 5 types of response:


Category Reason Phrases

1XX

Informational (Informational status code)

The received request is being processed

2XX Success (Success status code) Request normal processing complete
3XX Redirection (Redirected status code) Requires an additional operation completed request
4XX Client error (Customer fault status code) The server cannot process the request
5XX Server error (server-side fault status code) Server Processing Request Error


You can also change the status code defined in the RFC2616 or the server-side to create the status code as long as you follow the definition of the status Code category. The most commonly used and most representative 14 status codes are explained below.


4.2 2XX Success

The response of 2XX indicates that the request was processed normally.


OK

Indicates that a request from the client is handled properly on the server side. Within the response message, the information returned with the status code changes depending on the method. For example, when a Get method is used, the entity that corresponds to the requesting resource is returned as a response, but the entity header corresponding to the request resource does not return with the message subject as a response (that is, only the header is returned in the response, and the subject part of the entity is not returned) when the head method is used.
204 No Content The status code indicates that the request received by the server has been successfully processed, but the response message returned does not contain the body part of the entity . Also, it is not allowed to return the body of any entity. For example, when a request is processed from the browser and a 204 response is returned, the page displayed by the browser does not update. (Typically, the request is processed successfully, but no resources can be returned , only if you want to send the information from the client to the server and the client does not need to send the new message content)
206 Partial Content The status code indicates that the client made a scope request, and the server successfully executed the partial GET request. The response message contains the entity content specified by the Content-range ( request for a portion of the resource )


4.3 3XX redirect

3XX Response results indicate that the browser needs to perform some special processing to properly process the request.

301 movedpermanently

permanent redirection . The status code indicates that the requested resource has been assigned a new URI and should later use the URI that the resource now refers to. That is, if the URI of the resource is already saved as a bookmark, it should be re-saved by the URI of the Location header field prompt.

eg:http://example.com/sample===>http://example.com/sample/

302 Found Temporary redirection. The status code indicates that the requested resource has been assigned a new URI and that the user (this time) will be able to access it using the new URI. Similar to 301, but the 302 status code represents a resource that is not permanently moved but is temporary in nature.
303 See other The status code indicates that a request resource should be obtained by using the Get method, because another URI exists for the resource that corresponds to the request. The 303 status code and the 302 found status code have the same function, but the 303 status code clearly indicates that the client should take the Get method to obtain the resource, which differs from the 302 status code.
304 Not Modified This status code indicates when a client sends a request with a condition (typically, a request packet with a Get method contains a if-match,if-modifield-since,if-none-match,if-range, if-unmodified-since), the server-side allows requests to access resources, but does not meet the conditions. 304 When the status code returns, it does not contain any of the subject parts of the response. 304 Although in the 3XX category but not related to redirection
307 Temporary Redirect temporary redirection . The status code has the same meaning as 302 found. Although the 302 standard prohibits post from being converted to get, the actual use is not respected. 307 will follow the browser standard and will not change from post to get. However, there may be different scenarios for each browser when dealing with the behavior of the response.



4.4 4XX Client Error

The response of 4XX indicates that the client is the cause of the error.

Request
The status code indicates that there is a syntax error in the request message. When an error occurs, the requested content needs to be modified and sent again. In addition, the browser treats the status code as if it were OK.
401 Unauthorized This status code indicates that the request sent requires authentication with HTTP authentication (Basic authentication, Digest authentication). In addition, if 1 requests have been made before, the user authentication fails. Returns a response containing 401 must contain a www-authenticate header for the requested resource to challenge (Challenge) the user information. When the browser first receives a 401 response, the Authentication dialog window pops up.
403 Forbidden The Change status code indicates that access to the requested resource was rejected by the server. The server side does not need to give a detailed reason for the rejection, but if you want to do so, you can describe the reason in the body part of the entity so that the user can see it. "No access Authorization for the file system, access rights there are some questions (never authorized to send source IP address attempt to access) and so on, there may be 403 of reasons for the situation"
404 Not Found The status code indicates that the requested resource could not be found on the server. In addition, it can be used when the server denies the request and does not want to justify it.


401 Status Code Illustration

650) this.width=650; "Src=" Http://s5.51cto.com/wyfs02/M00/89/6E/wKiom1gSzmbTE-GVAACrPHwW0i8457.png-wh_500x0-wm_3 -wmp_4-s_1442332783.png "title=" 04-01.png "alt=" Wkiom1gszmbte-gvaacrphww0i8457.png-wh_50 "/>


4.5 5XX Server Error

The 5XX response indicates that the server itself has an error.

Internal Server Error The status code indicates that the server encountered an error while executing the request. It is also possible that a bug or some temporary failure exists in the Web application
503 Server Unavailable The status code indicates that the server is temporarily over-loaded or is undergoing downtime maintenance and cannot process the request now. If you know beforehand that it takes time to release the above situation, it is best to write the Retry-after header field back to the client.


PS: Status code and status inconsistencies

Many of the returned status code responses are wrong, but the user may not be aware of this. For example, there is an error inside the Web application, and the status code is still returned with a number of OK, which is often encountered.

Read "Schematic http" Summary--fourth Chapter

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.