Close

HTTP Message

[Updated: Dec 8, 2016, Created: Jun 22, 2016]

Web HTTP 

HTTP uses the client-server model. An HTTP client opens a connection and sends a request message to an HTTP server, the server then returns a response message, usually containing the resource that was requested.

HTTP request message consists of the followings in the given order:

  1. Request line: GET /xyz.html HTTP/1.1
  2. Host name: Host www.example.com
  3. Optional headers: Key value pair, separated by a colon (:) .
  4. An empty line.
  5. Optional Body.


Example

GET / HTTP/1.1
Host: www.example.com
Connection: keep-alive
Cache-Control: max-age=0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,..
Upgrade-Insecure-Requests: 1
User-Agent: Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/... Safari/537.36
Accept-Encoding: gzip, deflate, sdch
Accept-Language: en-US,en;q=0.8
If-None-Match: "359670651+gzip"
If-Modified-Since: Fri, 09 Aug 2013 23:54:35 GMT


An HTTP response message consists of the followings parts:

  1. Status line: HTTP/1.1 OK
  2. Headers: Key value pair.
  3. An empty line.
  4. Body.


Example

HTTP/1.1 304 Not Modified
Cache-Control: max-age=604800
Date: Mon, 01 Feb 2016 08:44:57 GMT
Etag: "359670651+gzip"
Expires: Mon, 08 Feb 2016 08:44:57 GMT
Last-Modified: Fri, 09 Aug 2013 23:54:35 GMT
Server: ECS (ftw/FBE4)
Vary: Accept-Encoding
X-Cache: HIT
x-ec-custom-error: 1

<html>
<head>
<title>Example Domain</title>

<meta charset="utf-8" />
<meta http-equiv="Content-type" content="text/html; charset=utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<style type="text/css">
.....
<body>
.....
.....
</body>
</html>


See Also