If you are having issues with the exercises, please create a ticket on DevZone:
Click or drag files to this area to upload. You can upload up to 2 files.

HTTP protocol

Hypertext Transfer Protocol (HTTP) is a TCP/IP-based application layer protocol used for communication and data transfer. HTTP is a request-response protocol with a client-server architecture. The client and server communicate by exchanging individual messages., clients initiate the exchange with an HTTP request, for example, GET, PUT DELETE, and POST, to name the most common.

HTTP is primarily utilized between web browsers and web servers. The web browser acts as the client and requests a web page’s content hosted on a server. When you type a URL into the web browser’s address field, the browser sends an HTTP request to the corresponding server, requesting web content. The server, in turn, processes the client’s requests and either provides the requested content in the form of an HTTP response or returns an error.

HTTP properties

HTTP is considered a connectionless and stateless protocol. Being connectionless refers to the fact that a connection’s lifecycle starts with the request and ends with the response, and no connection is preserved after the response from the server. This is advantageous as it prevents the hold-up of resources in idle times.

HTTP is considered a stateless protocol as each data exchange is independent from previous exchanges between the client and the server, which means the server does not keep a history of a client’s previous requests. This is in contrast with the File Transfer Protocol (FTP) for example, where the two entities may keep track of exchanged authentication credentials or the current working directory, for continuity and ease-of-access purposes. This can be an advantage for server implementations as it reduces complexity and eliminates the need for complex overhead data.

HTTP messages

HTTP communication is based on a request-response cycle, where the client sends an HTTP request message, containing information such as the request type and additional metadata, and the server responds with an HTTP response.

All HTTP messages are comprised of the following 3 main sections:

  1. Start-line: Describing either the request method (in an HTTP request) or the request status (in an HTTP response).
  2. Headers: (Optional) A message can contain zero or more header fields
  3. Body: (Optional) Contains data associated with the request

HTTP requests

The start-line of HTTP requests contains three things: the request method, the request target, and the HTTP version.

  1. Request method

The request method refers to the type of request the client wants to initiate. Some of the most common ones are:

  • POST: Used to submit data to the server, such as submitting a user-filled form.
  • PUT: Used to create or update the value of a resource on the server, for example updating a user’s information on the server.
  • GET: Used to retrieve a resource from the server, such as retrieving the contents of a specific webpage.
  • HEAD: Identical to a GET request, except it only requests the header of the response message, not the body, for example checking if a users’ information is on the server without retrieving the content.
  • DELETE: Used to delete a resource from the server, such as deleting a user’s entry from the server.

2. Request target

The Uniform Resource Identifier (URI) specifies the resource upon which one of the above methods is applied. A URI can be either a Uniform Resource Locator (URL) or a Uniform Resource Name (URN). However, URLs are more commonly used. An example of a URL is

3. HTTP version

This indicates the HTTP version being used in the request and is necessary to identify the structure of the rest of the message. And indicates which version to use for the HTTP response.

HTTP response

When an HTTP client, such as a web browser or a user using an HTTP API, sends an HTTP request to an HTTP server, the server responds with a status code explaining its response to that request. The three main response codes we will focus on in this lesson are:

  • 200 OK: This response indicates that the request has been processed successfully and the server has sent the required content in the response message’s body.
  • 404 Not Found: This response means that the server could not locate the requested content.
  • 403 Forbidden: This response means the HTTP client is requesting content which its not authorized to access or retrieve.
Register an account
Already have an account? Log in
(All fields are required unless specified optional)

  • 8 or more characters
  • Upper and lower case letters
  • At least one number or special character

Forgot your password?
Enter the email associated with your account, and we will send you a link to reset your password.