How HTTP Works
In this lesson, we'll look at the mechanics of HTTP a little more closely.
We'll cover the following...
As we’ve seen before, HTTP follows a request/response model where a client connected to the server issues a request and the server replies back to it.
An HTTP message (either a request or a response) contains multiple parts:
- start line
- headers
- body
HTTP requests
In a request, the start line indicates the verb used by the client, the path of the resource it wants, and the version of the protocol it is going to use.
GET /players/lebron-james HTTP/1.1
In this case, the client is trying to GET
the resource at /players/lebron-james
through version 1.1
of the protocol. This shouldn’t be nothing hard to understand.
Headers
After the start line, HTTP allows us to add metadata to the message through headers which take the form of key-value pairs separated by a colon.
GET /players/lebron-james HTTP/1.1
Host: nba.com
Accept: */*
Coolness: 9000
In this request, for example, the client has ...