First we look at a 360 browser used in the development of the following:
Above status code: OK (This is the status code)
1. The status code is used primarily for server-to-request processing results, which is a three-bit decimal number. The response status code is divided into 5 classes, as follows:
100~199: Indicates a successful receive request that requires the client to continue submitting the next request in order to complete the process.
200~299: Indicates a successful receive request, and has completed the entire processing process , commonly used isa.
300~399: To complete the request, the customer needs to refine the request further. For example, the requested resource has moved a new address, which is commonly used as 302/304.
400~499: The client's request has errors, commonly used 404.
500~599: Server side error, commonly used.
2. Examples of the actual application of HTTP responses
(1) Status Code 302 use
We now want to access the a.php page and have it automatically redirected to b.php
We are in the PHP installation file Htdos/http (in Htdos to create a new HTTP folder), which are written in a.php and b.php, the code of the two are as follows:
a.php:
<? PHP // This code will send a 302 status code to the client, telling the browser to jump to access b.php Header ("location:b.php");? >
b.php:
<? PHP Echo "B.php page"; ? >
We enter the URL in the browser: http://localhost/http/a.php, open the browser developer tool
The grab bag gets as follows: Get a.php (Status code:302), we view the location:b.php below
The server replies to the browser status code 302, which means to tell the browser to jump access to the b.php file (302 is like a jump condition )
Get b.php (Status code:200 ), this time there is no location
Extension, here can also jump to the outside network , that is, the a.php can be changed to the following code:
<? PHP // This code will send a 302 status code to the client, telling the browser to jump to access b.php //header ("location:b.php"); Header http://www.sohu.com");? >
(2) Status code 404 use
Our browser input accesses a nonexistent file address, http://localhost/http/c.php (here c.php is not present in the Access directory), the capture packet appears as follows:
The following is the details of the packet: Status Code:404 Not Found ( no corresponding file found, the page does not exist)
(3) Status Code 304 use
We write a d.php file at the htdos/http of the PHP installation file, as follows:
<? PHP Echo "Hello"; Echo ";? >
The first time in the browser to access this file, enter the address http://localhost/http/d.php, the following results appear:
The above reply brick status code is 200, I do not explain, said before, when we refresh this access page, the following results will appear:
Click to enter the parsing of the second packet:
(1) First we look at this request:
If-modified-since:if-modified-since is the header that the client sends to the server, and as you can see, when you request a locally-existing cache page again, the client passes the If-modified-since header Previous server-side sent Last-modified last modified timestamp sent back , this is to let the server side to verify , through this timestamp to determine whether the client's page is up-to-date, if not the latest, then return the new content, if it is the latest, then Return 304 tells the client that its local cache page is up-to-date, so the client can load the page directly from the local, so that the data transmitted over the network will be greatly reduced and the burden on the server is mitigated.
If-none-match: "3000000012e37-22006-51c86b9113ba4" This is sent to the server, the principle is to add etags information in the HTTP response. When the client requests the resource again, the If-none-match information (the value of etags) is added to the HTTP request. If the server verifies that the etags of the resource has not changed (the resource has not changed), it will return a 304 state, otherwise the server will return a 200 status and return the resource and the new etags.
PHP note 06:http status code in response