HTTP stands for Hypertext Transfer Protocol. It is an application layer protocol used across the world wide web and beyond, it typically runs on top of TCP. It enables browsers, and other applications, to ask web servers for pages which they can display. It was born as part of the WorldWideWeb project led by Tim Berners Lee and his team at CERN. It was officially introduced as HTTP V1.0 in RFC 1945 in 1996. HTTP has been assigned TCP port 80 by IANA. Today HTTP/1.1 is the most commonly used.
It is a request – response protocol with a ‘user agent’ acting as a client which communicates with a server. HTTP headers are used to provide information about the request or response whilst the body of the message contains the content to be rendered by the client or to be processed by the server.
The web browser will make a GET request to the server and will specify the location of the resource it is requesting and the version of HTTP it wants to use. There will just be a header, no request body.
HTTP/1.1 HEADER Request URL: https://example.com/page.html Request Method: GET Host: example.com
The server returns a response. If it could complete the request, this will have a code of 200 (which means ok) and include the contents of the desired resource (page.html) in the body of the response.
HTTP/1.1 Header Response: 200 OK Date: Mon, 01, Jan, 2001 13:00:00 GMT Content Type: text/html HTTP/1.1 BODY <html> <head> <title> Hello World </title> </head> <body> <h1>Hello World</h1> <p> This is a page. </p> </body> </html>
The web browser then uses the data in the body to render the page.
It may be necessary to make further requests to get other objects needed by the page such as CSS style sheets and images which can also be retrieved using HTTP.
There are various request methods which can be used with HTTP.
Request a resource from a server. GET requests should not change or delete any resources on the server.
HTTP POST requests are used to create new data on the server – often adding an entry to a database.
Update or create a resource.
Delete a resource from a server.
A response includes a status code to indicate the result of the request. HTTP status codes are 3 digits and are broken into different categories, indicated by the first digit. A full list of status codes for HTTP/1.1 is given in RFC 2616 section 10.
301 Moved Permanently
302 Found (non permanent redirect)
400 Bad Request
404 Not Found
418 I’m a teapot
500 Internal Server Error
503 Service Unavailable