Anatomy of a HTTP message
HTTP messages, as defined in HTTP/1.1 and earlier, are human-readable. In HTTP/2, these messages are embedded into a binary structure, a frame, allowing optimizations like compression of headers and multiplexing.
There are two types of HTTP messages, requests and responses, each with its own format.
Requests
GET / HTTP/1.1
Host: developer.mozilla.org
Accept-Language: fr
It consists of:
- HTTP method, a verb like GET, POST etc http-methods that defines the operation the client wants to perform.
- The path of the resource to fetch; the URL of the resource stripped from elements that are obvious from context
- The version of the HTTP protocol
- Optional headers that convey additional information to the servers
- A body for some methods like POST, similar to those in responses
Responses
HTTP/1.1 200 OK
Date: Sat, 09 Oct 2019 14:28:02 GMT
Server: Apache
Last-Modified: Tue, 01 Dec 2009 20:18:22 GMT
ETag: "fjsdiog-ear34538-sdfkjtghwio"
Accept-Ranges: bytes
Content-Length: 29769
Content-Type: text/html
It consists of:
- The version of the HTTP protocol they follow
- A status code http-status-codes, indicating if the request was successful
- A status message, a non-authoritative short description of the status code
- HTTP headers, like those for requests
- Optionally, a body containing the fetched resources
References
#what #http #code #communication #web #protocol #hypertext #server #internet #network #header #flow #html #node #exchange