HTTP Message Structure
HTTP is based on the client/server (C/S) architecture model, exchanging information through a reliable connection, and is a stateless request/response protocol.
An HTTP "client" is an application (such as a web browser or any other client) that connects to a server to send one or more HTTP requests.
An HTTP "server" is also an application (typically a web service, such as Apache Web Server or IIS Server, etc.) that receives client requests and sends HTTP response data to the client.
HTTP uses Uniform Resource Identifiers (URIs) to transmit data and establish connections.
Once a connection is established, data messages are sent using a format similar to that used by Internet mail [RFC5322] and the Multipurpose Internet Mail Extensions (MIME) [RFC2045].
Client Request Message
A client sends an HTTP request to the server's request message, which includes the following format: request line, request headers, an empty line, and request data. The figure below shows the general format of a request message.
Server Response Message
An HTTP response consists of four parts: status line, message headers, an empty line, and the response body.
Example
The following example is a typical use of GET to transmit 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.