Requests

Anatomy of a request

Read the request line, headers, blank line, and optional body that make up a complete HTTP request message.

7 minute lesson

~~~

An HTTP/1.1 request can be shown as plain text:

POST /notes HTTP/1.1
Host: example.com
Content-Type: application/json
Content-Length: 24

{"title":"Learn HTTP"}

The first line contains the method, request target, and protocol version.

Headers follow as name-value pairs. They add context about the host, accepted formats, authentication, caching, and the body.

An empty line marks the end of the headers. A body may follow. POST, PUT, and PATCH often carry one. GET normally does not.

HTTP/2 and HTTP/3 encode messages differently on the wire, but the same concepts remain: method, target, headers, and an optional body.

Lesson completed