HTTP detailed t...login
HTTP detailed tutorial
author:php.cn  update time:2022-04-11 13:41:55

HTTP message structure


HTTP is based on the client/server (C/S) architecture model. It exchanges information through a reliable link and is a stateless request/response protocol.

An HTTP "client" is an application (a web browser or any other client) that connects to a server for the purpose of sending one or more HTTP requests to the server.


An HTTP "server" is also an application (usually a Web service, such as Apache Web server or IIS server, etc.), which receives the client's request and sends HTTP to the client. response data.


HTTP uses Uniform Resource Identifiers (URI) to transmit data and establish connections.

Once the connection is established, data messages are sent using a format similar to that used by Internet mail [RFC5322] and Multipurpose Internet Mail Extensions (MIME) [RFC2045].


Client request message

The request message that the client sends an HTTP request to the server includes the following format: request line, request header It consists of four parts (header), blank line and request data. The following figure shows the general format of the request message.

2012072810301161


Server response message

HTTP response also consists of four parts, namely: status line, message header, blank line and response body.

httpmessage



Example

The following example is a typical example of using GET to transfer data:

Client Request:

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

Server response:

HTTP/1.1 200 OK
Date: Mon, 27 Jul 2009 12:28:53 GMT
Server: Apache
Last-Modified: Wed, 22 Jul 2009 19:15:56 GMT
ETag: "34aa387-d-1568eb00"
Accept-Ranges: bytes
Content-Length: 51
Vary: Accept-Encoding
Content-Type: text/plain

Output result:

Hello World! My payload includes a trailing CRLF.

php.cn