A website is usually run on what is called a web server. A web server is what’s needed to essentially make the web site accessible on the wider internet (amongst other things). A computer needs a standardised way of communicating with a web server. There are so many different flavours of operating systems, browsers, and devices and we need to make sure this communicate is consistent across all of them.
Enter HTTP. Hyper Text Transfer Protocol(HTTP) is this standardised method we’re talking about. HTTP usually works in the form of requests where a client (something like a browser) sends a request to complete a particular action to the website (technically the server). These actions can range from logging in and retrieving pages to adding some data (depending on the application of the website).
GET /login HTTP/1.1 [1]
Host: localhost:3000 [2]
User-Agent: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:61.0) Gecko/20100101 Firefox/61.0 [3]
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,/;q=0.8 [4]
Accept-Language: en-GB,en;q=0.5 [5]
Accept-Encoding: gzip, deflate [6]
Connection: close [7]
Upgrade-Insecure-Requests: 1 [8]
[1]
The first part is known as the HTTP verb that tells the server what kind of action the client is requesting. The most common types are:
While this is what they are commonly used for, they can be implemented incorrectly.
The second part refers to the path the action is directed towards - in this case the client is telling the server to get the login page. The third part refers to the protocol - in this case it is version 1.1 of the HTTP protocol.
Lines [2]-[8] are known as HTTP Headers. Headers are used by both the client and server to pass extra information to each respective entity. Headers are usually in the form Name: Value. Here’s a brief description of some of the request headers: