DEV Community

Bernice Waweru
Bernice Waweru

Posted on

HTTP: An Introduction

Hypertext Transfer Protocol (HTTP) is a client-server protocol for fetching resources allowing communication between the server and the client.

The client initiates the process by sending a request and the server returns the requested document as a response.

The document is constructed from different sub-documents fetched including, text, layout description, images, videos, and scripts.

The client combines these resources to render a web page that can be updated using the scripts.

Characteristics of HTTP

  1. HTTP is simple allowing for readability and ease of use
  2. HTTP is extensible and adaptable to various functionalities between the server and the client.
  3. HTTP is stateless and the server does not keep any data about the request. Each request is independent.

HTTP Messages

Two types of HTTP messages; Request and Response.
The request consists of the

  • HTTP method

This represents the operation the client wants to perform.

The most commonly used HTTP methods are GET, POST,PUT and UPDATE.

  • GET is used to retrieve resources from the server.
  • POST is used to send resources such as form data to the server.
  • DELETE is used to remove resources from the server
  • PUT is used to make changes to existing information in the server.
  • HEAD is used to get the headers of a get request without the body.
  • PATCH is used to make partial updates to resources.

Learn more HTTP methods here.

  • Path
    This is the path of the resources to be used. The URL of the resource.

  • Body
    Data sent to the server. POST,PUT and PATCH requests have request bodies.

  • optional headers
    The headers give the server more information about the request.

The response consists of the

  • HTTP response status codes

HTTP response status codes indicate whether a specific HTTP request has been successfully completed.
The status code fall under five categories:

  • Informational responses (100–199)
    These responses are used to give more information to the client on how to proceed while waiting for a response.

  • Successful responses (200–299)
    These indicate that the request was executed successfully and a response sent to the client successfully.

  • Redirection messages (300–399)
    These responses inform the client on where to find a resource if it has been moved or redirected elsewhere.

  • Client error responses (400–499)
    The response alert the client of an error on their side causing the server to be unable to process the request.

  • Server error responses (500–599)
    Inform the client that their request was not processed because of an error on the server side.
    Find specific status codes here

  • Headers
    The headers provide more information about the response.

  • Body
    This is the data returned in a response from the fetched resource.

Details on HTTPs will be covered in a future post.

Happy learning!!!

Discussion (0)