HyperText Transfer Protocol (HTTP)

Glazed over in three minutes

What the french fry is HTTP?

HyperText Transfer Protocol are the rules allowing the browser and the server to communicate through a request and response format.

Let’s walk through it.

You go to your browser, and type in http://www.google.com. This starts a conversation between your browser and many servers that handle the request. Just visiting this url initiates a GET request. What is a GET request? Get is the most used HTTP method which means that you want to get data/info/view on whatever is happening at http://www.google.com. This request is created in super strict way — meaning you have to send the request with all the information necessary for the server(s) to respond. The request contains headers, methods( like GET, POST, etc.), a body, and a URI. The body only exists if a ‘content-header’ is present. Example of what it would look like:

GET / HTTP/1.1
Host: google.com
Connection: keep-alive
Cache-Control: max-age=0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8
User-Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/38.0.2125.104 Safari/537.36
Accept-Encoding: gzip,deflate,sdch
Accept-Language: en-US,en;q=0.8
If-Modified-Since: Tue, 23 Jan 2017 04:44:06 GMT

Since it is sent correctly, the server responds with a response string containing the initial line which includes the status code (it would be 200 O.K. in this example) and version type, header lines (with information about the server environment) and a message body if present. If the request isn’t sent in the correct format that satisfies the protocol, the server will respond with an error (3XX for redirection, 4XX for client errors, 5XX for server errors). If it is sent correctly, it could look like this:

HTTP/1.1 200 OK
Content/type: text/html; charset-UTF-8
Date: Tue, 23 Jan 2017 04:44:06 GMT
Server: Apache
X-Powered-By: PHP/5.3.28
Cache-Control: max-age=3600
Content-Length: 1024

HTTP is a standard for communication on the world wide web. Remember client, server, request, response and RULES.

That’s it (for now)!