# HTTP Requests and Responses

> What HTTP is and what a request and a response look like line by line. What headers carry, and how to see them yourself with curl.

**Course:** [Computer Networking](https://learn.benibix.com/learn/infrastructure-networking)  
**Time:** 12 min

**After this lesson you can:**

- Read the first line of a request and a response
- Say what headers are for
- Look at real headers with curl

## What a browser sends, and what comes back

HTTP is the set of rules a browser uses to ask a server for a page. The browser sends a request, and the server sends back a response. Every web page, image and click on a website is one or more of these pairs. It is plain text, so you can read it.

A request starts with one line. First comes the method, such as GET, which says what to do. Then the path, such as /menu, which says which thing. Then the version of HTTP. So GET /menu HTTP/1.1 asks for the menu page.

Headers come next, one per line, each a name and a value. Host names the site, because one server can hold many sites. Accept says what kind of reply the browser can read. Other headers carry cookies, the language you prefer and which browser you use.

After the headers comes a blank line, then the body, if there is one. A plain page request has no body. A form you submit sends its fields in the body. The blank line is how the server knows the headers have ended.

The response has the same shape. Its first line holds the version and a three-digit code, such as 200, which means it worked. Then come headers about the reply, such as its size and how long it may be kept. Then the body: the page, the image or the data.

Each pair stands alone. The server does not remember your last request by itself. That is why sites use cookies: a small value the server hands over once, which the browser sends back in a header every time after.

A common mistake is to look only at the page and never at the headers. When a site acts strangely, the headers often explain it. The curl command with -I shows them for any address, in a second.

```console
$ curl -I https://emmas-shop.com/menu
HTTP/2 200
content-length: 5120
cache-control: max-age=60
```
The -I asks only for the headers. The first line says the version and the code, 200 for success.

![Two panels joined by arrows. On the left, the request from the browser: the line GET /menu HTTP/1.1, labelled method, path and version, then headers Host and Accept, then a blank line and a body if there is one. On the right, the response from the server: HTTP/1.1 200 OK, labelled version and a three-digit code, then headers for length and caching, then the page itself.](https://learn.benibix.com/diagrams/infc-http-exchange.svg)

### Example: A bakery's page will not update

Lucy changes the prices on her bakery's site, but customers still see the old ones. She runs curl -I on the page.

The response says the page may be kept for 86,400 seconds, a whole day. She sets it to 60 seconds, and the new prices show up within a minute.

**Words in this lesson:** [HyperText Transfer Protocol (HTTP)](https://learn.benibix.com/term/infrastructure/http), [HTTP Request](https://learn.benibix.com/term/infrastructure/http-request), [HTTP Response](https://learn.benibix.com/term/infrastructure/http-response), [HTTP Header](https://learn.benibix.com/term/infrastructure/http-header)

**Question:** What are HTTP headers for?

**Answer:** They carry extra facts about the request or reply, one name and value per line. Headers are labels on a request or a response: the site's name, the kind of reply wanted, how long to keep it. The page itself is in the body.

---

Source: https://learn.benibix.com/learn/infrastructure-networking/http-requests-and-responses
Author: Behnia Zarei (a developer in Vienna, Austria, who builds and teaches data, AI and business intelligence at BENIBIX)
Publisher: BENIBIX Learn (https://learn.benibix.com/)
Last updated: 2026-11-19
Licence: CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Quote freely with attribution.
