Script Valley
HTTP & The Web: How It Actually Works
HTTP FundamentalsLesson 2.1

HTTP request and response structure explained

request line, response status line, HTTP headers, message body, CRLF, Content-Type, Content-Length, Host header

Anatomy of an HTTP Message

HTTP request and response structure diagram

HTTP is a text protocol. Every request and response is a structured text message with three parts: a start line, headers, and an optional body separated by a blank line.

HTTP Request

GET /api/users HTTP/1.1

Host: api.example.com

Accept: application/json

Authorization: Bearer eyJhbGc...



The first line is the request line: method + path + HTTP version. Headers follow as Name: Value pairs, each ending in CRLF ( ). A blank line (double CRLF) signals the end of headers. The body follows โ€” absent for GET requests.

HTTP Response

HTTP/1.1 200 OK

Content-Type: application/json

Content-Length: 42



{"id": 1, "name": "Alice"}

The first line is the status line: HTTP version + status code + reason phrase. Headers follow, then a blank line, then the optional body.

Required headers

HTTP/1.1 mandates the Host header on every request โ€” without it, virtual hosting fails because one server IP may serve dozens of domains. The server uses Host to route to the correct application. When a body is present, either Content-Length or Transfer-Encoding: chunked is required so the receiver knows where the message ends and the next one begins.

# See raw HTTP with curl
curl -v https://httpbin.org/get 2>&1 | head -30

Up next

HTTP methods GET POST PUT PATCH DELETE: when to use each

Sign in to track progress

HTTP request and response structure explained โ€” HTTP Fundamentals โ€” HTTP & The Web: How It Actually Works โ€” Script Valley โ€” Script Valley