Latest web development tutorials

HTTP message structure

HTTP is a client / server (C / S) architecture model, to exchange information via a secure link, is a stateless request / response protocol.

A HTTP "client" is an application (Web browser or any other client), by sending a request to connect to the server to achieve one or more of the HTTP server purposes.

A HTTP "server" is also an application (usually a Web service, such as Apache Web Server or IIS server, etc.), by receiving the client's request to the client to send HTTP response data.

HTTP uses uniform resource identifier (Uniform Resource Identifiers, URI) to transmit data and establish a connection.

Once the connection is established, the data message on the Internet via e-mail format similar to that used [RFC5322] and Multipurpose Internet Mail Extensions (MIME) [RFC2045] to transmit.


Client request message

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

2012072810301161


Server response message

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

httpmessage



Examples

The following example is a little typical use GET to pass the instance data:

Client requests:

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:

Hello World! My payload includes a trailing CRLF.