Introduction to HTTP
The HTTP protocol is an abbreviation for the Hyper Text Transfer Protocol (Hypertext Transfer Protocol), which is used to transfer hypertext to the local browser from the World Wide Web (www:world Wide Web) server.
HTTP is a TCP/IP communication protocol that transmits data (HTML files, image files, query results, and so on).
How HTTP Works
The HTTP protocol works on the client-server architecture. The browser sends all requests via URLs to the HTTP server, which is the Web servers, as an HTTP client.
The Web server has: Apache server, IIS server (Internet information Services) and so on.
The Web server sends a response message to the client, based on the received request.
The HTTP default port number is 80, but you can also change to 8080 or another port.
HTTP three-point considerations:
- HTTP is no connection: the meaning of no connection is to limit the processing of only one request per connection. When the server finishes processing the customer's request and receives the customer's answer, the connection is disconnected. In this way, the transmission time can be saved.
- HTTP is media Independent: This means that any type of data can be sent over HTTP as long as the client and the server know what to do with the data content. The client and server specify that the appropriate Mime-type content type be used.
- HTTP is stateless: The HTTP protocol is a stateless protocol. Stateless means that the protocol has no memory capacity for transactional processing. A lack of state means that if the previous information is required for subsequent processing, it must be re-routed, which may cause the amount of data to be transferred per connection to increase. On the other hand, it responds faster when the server does not need the previous information.
The HTTP protocol communication flow is shown in the table:
HTTP status Code
When a viewer accesses a webpage, the browser of the viewer makes a request to the server where the page is located. When a Web page is received and displayed by the browser, the server on which the page resides returns a message header (server header) that contains the HTTP status code to respond to the browser's request.
HTTP status code in English is HTTP status code.
The following are the common HTTP status codes:
- 200-Successful request
- 301-Resources (Web pages, etc.) are permanently transferred to other URLs
- 404-The requested resource (Web page, etc.) does not exist
- 500-Internal Server error
HTTP status Code classification
The HTTP status code consists of three decimal digits, the first decimal number defines the type of the status code, and the latter two numbers do not have a function of classification. There are 5 types of HTTP status codes:
HTTP status Code classification
category |
Category Description |
1** |
Information, the server receives the request and requires the requestor to continue the operation |
2** |
Successful, the operation is successfully received and processed |
3** |
Redirect, requires further action to complete the request |
4** |
Client error, request contains syntax error or cannot complete request |
5** |
Server error, the server has an error while processing the request |
HTTP Status Code list:
HTTP status Code list
Status Code |
Status Code English name |
Chinese Description |
100 |
Continue |
Go on. The client should continue its request |
101 |
Switching protocols |
Switch protocols. The server switches the protocol based on the client's request. You can only switch to a more advanced protocol, for example, a new version of the protocol that switches to HTTP |
|
200 |
Ok |
The request was successful. Typically used for Get and post requests |
201 |
Created |
has been created. A new resource was successfully requested and created |
202 |
Accepted |
has been accepted. The request has been accepted, but the completion is not processed |
203 |
Non-authoritative Information |
Non-authorized information. The request was successful. But the meta information returned is not on the original server, but a copy |
204 |
No Content |
No content. The server processed successfully, but the content was not returned. Make sure the browser continues to display the current document without updating the page |
205 |
Reset Content |
Resets the content. The server processing succeeds, and the user terminal (for example: browser) should reset the document view. The browser's form fields can be cleared by this return code |
206 |
Partial Content |
Part of the content. The server successfully processed a partial GET request |
|
300 |
Multiple Choices |
Multiple options. The requested resource can include multiple locations, which can return a list of resource characteristics and addresses for use in the user terminal (for example: browser) selection |
301 |
Moved Permanently |
Move permanently. The requested resource has been permanently moved to the new URI, the return information will include the new URI, and the browser will automatically redirect to the new URI. Any future new requests should be replaced with a new URI |
60W |
Found |
Temporary move. Similar to 301. But resources are only temporarily moved. The client should continue to use the original URI |
303 |
See other |
See other addresses. Similar to 301. Viewing with Get and post requests |
304 |
Not Modified |
Not modified. The requested resource is not modified and no resources are returned when the server returns this status code. Clients typically cache accessed resources by providing a header indicating that the client wants to return only the resources modified after the specified date |
305 |
Use Proxy |
Use a proxy. The requested resource must be accessed through the proxy |
306 |
Unused |
HTTP status codes that have been discarded |
307 |
Temporary Redirect |
Temporary redirection. Similar to 302. REDIRECT with GET request |
|
400 |
Bad Request |
Client request syntax error, server does not understand |
401 |
Unauthorized www.jusho.cn |
Request for user authentication |
402 |
Payment Required |
Reserved for future use |
403 |
Forbidden |
The server understands the request from the requesting client, but refuses to execute the request |
50U |
Not Found www.pipixiaa.com |
The server could not find the resource (Web page) based on the client's request. With this code, the Web designer can set up a personalized page that "the resource you requested could not be found" |
405 |
Method not allowed |
The method in the client request is forbidden |
50W |
Not acceptable |
The server cannot complete the request based on the content attributes requested by the client |
407 |
Proxy Authentication Required |
The request requires the authentication of the agent, similar to 401, but the requestor should use the proxy for authorization |
408 |
Request time-out |
The server waits for a client to send a request that is too long and times out |
409 |
Conflict |
It is possible for the server to complete a put request from the client to return this code when the server handles the request and a conflict occurs |
410 |
Gone www.foodtvl.com |
The resource requested by the client no longer exists. 410 is different from 404, if the resource is now permanently deleted and can use 410 code, the site designer can specify a new location for the resource through 301 code |
411 |
Length Required |
The server cannot process request information sent by the client without content-length |
412 |
Precondition Failed |
Prerequisite error for client request information |
413 |
Request Entity Too Large |
The request was rejected because the requested entity was too large to be processed by the server. To prevent successive requests from the client, the server may close the connection. If only the server is temporarily unable to process, it will contain a retry-after response message |
414 |
Request-uri Too Large |
The requested URI is too long (the URI is usually the URL) and the server cannot process |
415 |
Unsupported Media Type |
The server cannot process the media format that was included with the request |
416 |
Requested range not satisfiable |
Invalid scope for client request |
417 |
Expectation Failed |
Server failed to satisfy expect request header information |
|
500 |
Internal Server Error |
Server internal error, unable to complete request |
501 |
Not implemented |
The server does not support the requested feature and cannot complete the request |
502 |
Bad Gateway |
A server acting as a gateway or proxy that received an invalid request from the remote server |
503 |
Service unavailable |
Due to overloading or system maintenance, the server is temporarily unable to process client requests. The length of the delay can be included in the server's Retry-after header information |
504 |
Gateway time-out |
A server that acts as a gateway or proxy and does not get requests from the remote server in time |
505 |
HTTP Version not supported |
The server does not support the version of the requested HTTP protocol and cannot complete processing |
HTTP Introduction HTTP Works HTTP three-point considerations: