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 Hy…


This content originally appeared on DEV Community and was authored by Dylan Britz

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 HTTP is a protocol. 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 an HTTP request to the web
  2. A web server receives the request
  3. The server runs an application to process the request
  4. The server returns an HTTP 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.

What’s 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.

What’s 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

What’s 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.

What’s 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.


This content originally appeared on DEV Community and was authored by Dylan Britz


Print Share Comment Cite Upload Translate Updates
APA

Dylan Britz | Sciencx (2022-03-30T18:59:36+00:00) What is HTTP & How Does It Work?. Retrieved from https://www.scien.cx/2022/03/30/what-is-http-how-does-it-work/

MLA
" » What is HTTP & How Does It Work?." Dylan Britz | Sciencx - Wednesday March 30, 2022, https://www.scien.cx/2022/03/30/what-is-http-how-does-it-work/
HARVARD
Dylan Britz | Sciencx Wednesday March 30, 2022 » What is HTTP & How Does It Work?., viewed ,<https://www.scien.cx/2022/03/30/what-is-http-how-does-it-work/>
VANCOUVER
Dylan Britz | Sciencx - » What is HTTP & How Does It Work?. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2022/03/30/what-is-http-how-does-it-work/
CHICAGO
" » What is HTTP & How Does It Work?." Dylan Britz | Sciencx - Accessed . https://www.scien.cx/2022/03/30/what-is-http-how-does-it-work/
IEEE
" » What is HTTP & How Does It Work?." Dylan Britz | Sciencx [Online]. Available: https://www.scien.cx/2022/03/30/what-is-http-how-does-it-work/. [Accessed: ]
rf:citation
» What is HTTP & How Does It Work? | Dylan Britz | Sciencx | https://www.scien.cx/2022/03/30/what-is-http-how-does-it-work/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.