HTTP protocol Simple parsing

Source: Internet
Author: User

HTTP protocol (reprinted from the Ox-Guest network unknown Great God) 1. Introduction to the HTTP protocol (Hyper text Transfer Protocol, Hypertext Transfer Protocol), is used to transfer hypertext to the local browser from the World Wide Web (www:world Wide Web) Server Transfer Protocol.  HTTP transmits data based on the TCP/IP communication protocol. HTTP based on the client/server-side (c/s) architecture model, a reliable link to exchange information, is a No statusRequest/Response protocol. 2. Features (1) 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. (2) HTTP is media Independent: As long as the client and the server know how to handle the data content, any type of data can be sent over HTTP.  The client and server specify that the appropriate Mime-type content type be used. (3) HTTP is stateless: 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. 3. Communication Flow 4. Message structure

HTTP uses a Uniform Resource identifier (Uniform Resource Identifiers, URI) to transfer data and establish a connection. Once the connection is established, the data message is routed through the format [RFC5322] and Multipurpose Internet Mail Extensions (MIME) [RFC2045] that are used by similar Internet mail.

Client Request message: Request line, request header, blank line, and request data.
1234 Get/hello.txt http/1.1 user-agent:curl/7.16.3 libcurl/7.16.3 openssl/0.9.7l zlib/1.2.3 Host:www.example.com Accept-language:en, MI
Service-side Response message: status line, message header, blank line, and response body.
123456789 http/1.1 Okdate:mon, 12:28:53 gmtserver:apachelast-modified:wed, the 19:15:56 gmtetag: "34aa387 -d-1568eb00 "Accept-ranges:bytescontent-length:51vary:accept-encodingcontent-type:text/plain
5. The Request method Get request Specifies the page information and returns the entity principal. HEAD is similar to a GET request, except that there is no specific content in the returned response, which is used to get the header post to submit data to the specified resource for processing requests (such as submitting a form or uploading a file). The data is included in the request body. A POST request may result in the creation of new resources and/or modification of existing resources. PUT replaces the contents of the specified document with the data that the client transmits to the server. The delete request server deletes the specified page. The Connect http/1.1 protocol is reserved for proxy servers that can change connections to pipelines. The OPTIONS allows clients to view server performance. TRACE echoes the requests received by the server, primarily for testing or diagnostics. 6. Status Code HTTP status code classification
1** information, the server receives the request, requires the requestor to continue the Operation 2** successful, the operation is successfully received and handles 3** redirection, requires further action to complete the request 4** the client error, the request contains a syntax error or cannot complete the request 5** server error, The server has had a wrong HTTP status code list during processing of the request. Continue continue. The client should continue its request 101 switching protocols switch protocol. 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 HTTPThe request was successful. Typically used for Get and post requests201 Created has been created. A new resource was successfully requested and created 202 Accepted accepted. The request has been accepted, but the 203 non-authoritative information is not processed to complete the non-authorized information. The request was successful. But the meta information returned is not in the original server, but a copy of 204 no content. The server processed successfully, but the content was not returned. If the page is not updated, ensure that the browser continues to display the current document 205 reset content. The server processing succeeds, and the user terminal (for example: browser) should reset the document view. This return code can be used to clear the contents of the 206 partial content of the browser's form field. The server successfully processed some of the get requests for 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) selection301 Moved Permanently permanent movement. 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 URI302 Found Temporary movement. Similar to 301. But resources are only temporarily moved. The client should continue to use the original URI303 see other to view other addresses. Similar to 301. Viewing with Get and post requests304 Not Modified has not been 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 date305 Use Proxy. The requested resource must access the HTTP status Code 306 Unused has been discarded through the proxy307 Temporary Redirect temporary redirection. Similar to 302. Redirect with GET requestThe syntax error of the request client requests, the server does not understand the 401 unauthorized request requires the user's identity authentication 402 Payment Required reserved, future use 403 Forbidden server understand the request client Request, but refuses to execute the request404 Not the Found server could not find resources (Web pages) based on client requests. 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 in the client request is disabled 406 not acceptable the server cannot complete the request based on the content attributes requested by the client 407 Proxy authentication Required request Proxy identity Authentication, similar to 401, but the requestor should use the proxy to authorize the 408 request time-out server waiting for the client to send the requested time too long, timed out 409 Conflict the server to complete the client's put request is likely to return this code, the server processing the request when the conflict occurred 4 The resource requested by the Gone client no longer exists. 410 is different from 404, if the resource has been permanently deleted now can use 410 code, the site designer can specify the new location of the resource through 301 code 411 Length Required Server cannot process request information sent by client without Content-length 412 Precondition Failed client request information for a prerequisite error 413 request entity Too Large because the requested entity is too large for the server to process, and therefore rejects requests. 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 information 414 Request-uri Too Large The URI of the request is too long (URI is usually the URL), the server cannot process the 415 unsupported Media Type server Unable to process the media format that came with the request 416 requested range not satisfiable the range of client requests is invalid 417 expectation Failed Server could not satisfy expect request header informationInternal Server error Server internal errors, unable to complete the requestThe 501 not implemented server does not support the requested feature and cannot complete the request 502 Bad gateway acts as a gateway or proxy server, receiving 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 acting as a server for gateways or proxies, not getting requests from the remote server in time 505 HTTP Version not supported the server does not support the requested HTTP Version of the Protocol, unable to complete processing

HTTP protocol Simple parsing

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.