Your Web News in One Place

Help Webnuz

Referal links:

Sign up for GreenGeeks web hosting
September 15, 2021 03:18 pm GMT

Hyper-Text TransferProtocol - HTTP 101

What On Earth is HTTP

HTTP is a request response protocol that define some sets of rules through which client and server communicate over an already established TCP connection.

Once an TCP connection has been established between client and server, HTTP defines rules for transferring data such as images, text, multimedia etc.

HTTP is not a connection protocol it relies on TCP to establish connection between client and server. Once the server receives HTTP request message sent by client over an opened TCP connection, the server analyses and sends an HTTP response to the client after which TCP connection is closed

And there is no relation or link between two or more HTTP request message sent consecutively over a same TCP connection.

Establishing an HTTP connection

When a client initiates an request-response cycle it performs the following steps:

  • An TCP connection is established
  • Once TCP connection is established the client sends an HTTP request message to the server and server responds to that message
  • TCP connection is closed

HTTP Messages

There are two types of HTTP message HTTP request msg and HTTP response message

HTTP Request Message

An HTTP request message consist of the following

Fhk3an1Va

  • HTTP Method: These define the nature of request in the above case the method is a GET request
  • Request URI: This identifies the resource upon which HTTP method is to be applied. In the above case its /explore
  • HTTP Version: In the above case its HTTP/1.1
  • HTTP Request Headers: Then Comes the request headers which convey some additional info to the server about the request and client. In the above case we have the following request headers
    1. Host: It contains the IP and Port number of the server where website or resource is stored. In this case its [hashnode.com](http://hashnode.com) and default port number for HTTP is 80 and for HTTPS its 443
    2. Accept-Language: This specifies the language in which client wish to communicate in the above case it en (English)
  • HTTP Request Body: This is an optional feild that contains info being sent for storage, mainly used in POST, PATCH request etc

HTTP Response Message

An HTTP response message consist of the following

1Unf9vpWu

  • HTTP Version: In the above case its HTTP/1.1
  • Status Code: Determines the result of request, in this case its 200
  • HTTP Response Headers: Conveys additional info about the response and server to the client, in this case we are having the following headers
    1. Accept Ranges: It is used by the server to show its support for partial requests
    2. Server: This tells about the nature of server which process the response, In this case its Apache
    3. Content-Type: This indicates the file type of resource, In this case its a html or a txt file
    4. E-Tag: it identifies the specific resource version
  • HTTP Response Body: This is an optional field that contains info sent from server to client mainly in requests like GET request

HTTP Methods:

  • GET - This method retrieves the resource specified in the request-URI. If successful the resource is returned as an entity in the response message along with the status code 200 (Success).
  • POST - This method is used to modify data in server if successful the server responds by sending a response message containing the status code 201 (Created), along with the location of the posted entity or data.
  • PUT - Update data in server
  • DELETE - Delete data in server

HTTP Status Codes:

Common-HTTP-error-Blog-Post-Image
httpStatusCode_de_en

Read More Over here:

HTTP: Hypertext Transfer Protocol (article) | Khan Academy


Original Link: https://dev.to/uzairali10/hyper-text-transfer-protocol-http-101-4jp4

Share this article:    Share on Facebook
View Full Article

Dev To

An online community for sharing and discovering great ideas, having debates, and making friends

More About this Source Visit Dev To