It is the last evening of the application deadline for a government job circular. The form is filled in, the photo is uploaded, and the cybercafé is packed with people doing exactly the same thing. You press Submit. The button turns grey. Ten seconds pass, and then a plain white page appears with two lines on it: 502 Bad Gateway.
Questions arrive all at once. Was my application received? If I press Submit again, will it be counted twice, or refused the second time? Is the fault in my connection, in my browser, or in the website? And what is a "gateway", when I never walked through one? Everything you need to answer these is a short list of rules that every web page you have ever opened obeys: who speaks first, what a message looks like, what a three-digit number means, and which requests are safe to repeat.
By the end of this chapter you will be able to read a raw HTTP request and response line by line and say what each line is for. You will say what URL, URI, URN, HTTP and HTTPS stand for, resolve a relative link against the page it sits on, and build a query string that does not break when a value contains an &.
You will say what travels in the body of a request and how the receiver knows where the body ends. You will tell safe from idempotent and explain why that difference decides whether a request may be repeated. You will pick the right status code for a situation and work out whose fault a failure is. And you will explain what "HTTP is stateless" costs and what it buys, and calculate how long a page takes to load with and without persistent connections.