Labs / Speaking Protocols / HTTP, TLS & mail

Lab 1 of 4 · HTTP, TLS & mail

HTTP up close: requests, answers and connections

Type HTTP requests by hand and read every line of the answers.

Open this lab Pro 6 steps

The idea

HTTP requests are lines of text: the client writes a few lines, the server writes some back, over one TCP connection. Here the client is the laptop, and webServer is one nginx server that carries three sites.

The Host line picks the site
The Host line picks the site
One connection, or one per request
One connection, or one per request

Steps

  1. A request typed by hand

    Every browser and app speaks the same few lines of text, so you can speak them yourself. nc opens a TCP connection to webServer's Port 80 and sends each line you type. Type a request for the front page in HTTP/1.1, one line at a time, and read what comes back.

    laptop:~# nc webServer.lab 80
    laptop:~# nc webServer.lab 80
  2. Status codes: found, missing, moved

    A program reading the answer needs to know at once whether it worked, without reading the page. The number in the status line says so. Ask for a missing page, then a moved one, showing only the status line and headers.

    laptop:~# curl -sI http://webServer.lab/missing
    laptop:~# curl -sI http://webServer.lab/old-page
    laptop:~# curl -siL http://webServer.lab/sale

Pro

4 more steps in the app

  1. Methods: what the client wants done
  2. One address, three sites: the Host header
  3. Keep-alive: three requests, one connection
  4. Connection: close: a handshake per request
Get Pro

Learn it on real machines.

Every lab is a small network of real Linux machines in your browser. Start with a free account: Google or email, no card.

Open this lab