VCF

Unit 1 · How the web works

How to read an HTTP request and response

A request starts with a method and a path, such as GET /menu, and names the site in a Host line. The response starts with a status line, such as HTTP/1.1 200 OK, then headers, a blank line, and the page itself.

The mix-up

What people often think

“GET is part of the answer that came back.”

What the tutor says

GET is the browser's request: "please get me this". The answer starts with the status line, HTTP/1.1 200 OK.

How it works

The browser does not send the URL in one piece. The path goes on the first line and the domain travels separately in the Host header. The fragment is not sent at all.

GET belongs to the request: “please get me this”. The answer begins with the status line. Headers such as Content-Type: text/html are labels on the parcel saying what is inside; the content itself starts after the blank line.

An example

What worksHTTP
GET /menu HTTP/1.1
Host: cornerbakery.ca

HTTP/1.1 200 OK
Content-Type: text/html

<!doctype html>
<html>...
The request (top) and the start of the response (bottom).

Close cousins of this mix-up

The tutor watches for these in the same lesson.

  • “The browser sends the whole URL in one piece.”

    The URL is split up. The path goes on the first line, and the domain travels separately in the Host line.

  • “Content-Type is the content.”

    Content-Type is a label on the parcel saying what is inside. The page itself comes after the blank line.

  • “Everything in the address bar is sent to the server.”

    Look at the request: the path stops at /menu. The # part is never sent, which is why # routes are not separate pages.

Practise it with a tutor watching

Reading a request

Read a request and its response line by line, and write links that work.

20 minutes See it Build it Break it Say it
Start the lesson

Free, no account needed.