Your Web News in One Place

Help Webnuz

Referal links:

Sign up for GreenGeeks web hosting
March 30, 2022 06:59 pm GMT

What is HTTP & How Does It Work?

What is HTTP

In my previous post, we talked about the internet and how it works. In all the complexity of the internet as a web developer there is something very important you need to know and that is HTTP.

So what is HTTP

The Hypertext Transfer Protocol or HTTPis aprotocol. It is the foundation we use to fetch data over the internet (fancy explanation for communication between two devices). So servers and clients exchange messages between each other instead of a single open stream of data like some people might believe. Client messages are known as requests and Server messages are known as response.

How does HTTP work

  1. A client (a browser) sends anHTTP requestto the web
  2. A web server receives the request
  3. The server runs an application to process the request
  4. The server returns anHTTP response(output) to the browser
  5. The client (the browser) receives the response

As you can see above this process happens every single time your client(browser) request anything from the server. All files and data are fetched one at a time, one after the other and not asynchronously.

A typical HTTP request / response circle might look like this:

  1. The browser requests an HTML page. The server returns an HTML file.
  2. The browser requests a style sheet. The server returns a CSS file.
  3. The browser requests an JPG image. The server returns a JPG file.
  4. The browser requests JavaScript code. The server returns a JS file
  5. The browser requests data. The server returns data (in XML or JSON).

Each HTTP request made across the Internet carries with it a series of encoded data that carries different types of information. A typical HTTP request contains:

  1. HTTP version type
  2. a URL
  3. an HTTP method
  4. HTTP request headers
  5. Optional HTTP body.

Whats an HTTP method?

An HTTP method, also known as an HTTP verb, specifies the action that the HTTP request wants the requested server to take. The HTTP methods 'GET' and 'POST' are two of the most frequent; a 'GET' request expects information back in return (generally in the form of a website), whereas a 'POST' request normally implies that the client is providing information to the web server (such as form information, e.g. a submitted username and password).

What are HTTP request headers?

Every HTTP request includes HTTP headers, which comprise text information saved in key-value pairs. These headers convey important information, such as the client's browser and the material being requested.

Whats in an HTTP request body?

An HTTP response is the response that a web client receives from an Internet server in response to an HTTP request. These responses convey useful information based on what was requested in the HTTP request. A typical HTTP response contains:

  1. an HTTP status code
  2. HTTP response headers
  3. optional HTTP body

Whats an HTTP status code?

HTTP status codes are 3-digit codes most often used to indicate whether an HTTP request has been successfully completed. Status codes are broken into the following 5 blocks:

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

What are HTTP response headers?

An HTTP response, like an HTTP request, includes headers that convey important information such as the language and format of the data in the response body.

Whats in an HTTP response body?

Successful HTTP responses to 'GET' requests typically include a body containing the requested data. This is HTML data in most web requests, which a web browser will translate into a web page.


Original Link: https://dev.to/britzdylan/what-is-http-how-does-it-work-2i07

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