Hypertext Transfer Protocol (HTTP) is the foundation of the world wide web, it is an application layer protocol designed to transfer information between networked devices and runs on top of other layers of the network protocols. A typical flow over HTTP involves a client machine making a HTTP request to a server, which then sends a response message.

HTTP request

An HTTP request is the way services or applications (i.e. web browser) ask for the information they need to load a website. Each HTTP request made across the Internet carries with it a series of encoded data that contains different types of information:

  1. HTTP version type
  2. A Uniform Resource Locator (URL)
  3. An HTTP method
  4. HTTP request headers
  5. Optional HTTP body

HTTP request method

HTTP request method, indicates the action that the HTTP request desired from the queried server. The HTTP methods are an integral part of the HTTP protocol and are used by clients (i.e. web browser) to communicate with web servers. Each HTTP method has a specific purpose and behaviour.

  • GET The GET method is used to retrieve data or resources from a specified URL. It is similar to the R (Read) in the CURD operation.
  • POST The POST method is used to submit data to be processed to a specified URL. It is similar to the C (Create) in the CURD operation.
  • PUT The PUT method is used to update or replace a resource or data at a specified URL. It is similar to the U (Update) in the CURD operation.
  • DELETE The DELETE method is used to request the removal of a resource at a specified URL. It is similar to the D (Delete) in the CURD operation.

HTTP request header

HTTP header contains text information stored in key-value pairs, they exist in HTTP request and response. These headers communicate core information, such as what browser the client is using and what data is being requested. Example of HTTP request headers from Google Chrome’s network tab:

HTTP request body

The body of a request is the part that contains any information being submitted to the web server, such as a username, password, or any other data entered into a form. (In HTTP all information is sent in clear text, and transferred in public internet, therefore it is vulnerable to intersections. HTTPS is a secure HTTP that encrypts the data that is being retrieved by HTTP)

HTTP response

An HTTP response is what web clients (often web browsers) receive from an Internet server in answer to an HTTP request. These responses communicate valuable information based on what was asked for the HTTP request. A typical HTTP response contains:

  1. An HTTP status code
  2. HTTP response header
  3. Optional HTTP body

HTTP status code

HTTP status code are 3-digit codes that are returned by a web server to indicate the outcome of an HTTP request.

  • 1xx Informational
  • 2xx Success
  • 3xx Redirection
  • 4xx Client Error
  • 5xx Server Error

The “xx” refers to different numbers between 00 and 99.

HTTP response header

Similar to HTTP request header, an HTTP response header comes with headers that convey information such as the language and format of the data being sent in the response body.

HTTP response body

Successful HTTP responses to GET requests generally have a body which contains the requested information. In most web requests, this is HTML data that a web browser will translate into a webpage.

HTTP interaction process

When using HTTP to fetch a web page, several steps are involved in the communication process between the client (i.e. web browsers) and the web server that hosting the web page.

  1. DNS resolution When you entered a URL into your web browser’s address bar. Your web browser performs DNS resolution that translate the domain name in the URL to its corresponding IP address.
  2. TCP connection Once the IP address is obtained, your web browser establishes a TCP connection to the web server that hosting the website. The default TCP port for HTTP is port 80. The browser will initiate connection to the web server’s IP address on port 80.
  3. HTTP request After the TCP connection is established, your web browser sends an HTTP request to the web server.
  4. Web server processing The web server receives the HTTP request and processes it. It identifies the requested web page, retrieves it from the server’s file system or database, and prepares to send it back as an HTTP response.
  5. HTTP response The web server sends an HTTP response to your browser.
  6. Display web page Your web browser and web server engage in bidirectional data transfer over the established TCP connection. The web browser sends the web page’s HTML, CSS, JavaScript, images and other resources as part of the response. Your web browser receives the contents and begins to render the web page by processing the HTML, executing JavaScript code as needed to.

Back to parent node: Application Layer

Computer_networksINFO1112IP_modelApplication_layerHyper_Text_Transfer_Protocol_HTTPHTTP_status_codeHTTP_methodHTTP_responseHTTP_requestDomain_Name_System_DNSTCP_portInternet_Protocol_IPDNS_resolutionHTML