The following two headers try to give an idea how a HTTP request-response exchange might be executed.
Request
The
user agent requests a resource by sending a HTTP request to a
web server. The desired URI is
http://rene.nyffenegger.ch/notes/development/web/HTTP
So the client contacts the the server (renenyffenegger.ch) and sends a header that might look like.
GET /notes/development/web/HTTP/header HTTP/1.1
host: renenyffenegger.ch
user-agent: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:47.0) Gecko/20100101 Firefox/47.0
accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
accept-language: de
accept-encoding: gzip, deflate
referer: www.google.com
accept-charset: *
x-forwarded-for: …
x-forwarded-host: …
x-forwarded-server: …
connection: close
In the request header, the first line is the request line that specifies the request method (in this example GET
), the URI and the protocol Version (HTTP/1.1
).
The request line is followed by header fields, each of which has a name that is separated from its value by a colon (:
).
The header extends to the first empty line.
Response
The web server returns the requested resource along with a header.
The body of the resource is separated from the header by an empty line.
The first line of the response is a
status line that consists of
- HTTP Version (Format:
HTTP M/m
, M = Major number, m = minor number)
- A three-digit status code
- A character string that describes the status code
A potential response header from a
webserver might be:
HTTP/1.0 200 OK
Date: Wed, 4 Mar 2020 21:18:13 GMT
Content-Type: text/html; charset=UTF-8
Content-Length: …
<html>
…
</htm>