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
- A client (a browser) sends an HTTP request to the web
- A web server receives the request
- The server runs an application to process the request
- The server returns an HTTP response (output) to the browser
- 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:
- The browser requests an HTML page. The server returns an HTML file.
- The browser requests a style sheet. The server returns a CSS file.
- The browser requests an JPG image. The server returns a JPG file.
- The browser requests JavaScript code. The server returns a JS file
- 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:
- HTTP version type
- a URL
- an HTTP method
- HTTP request headers
- 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:
- an HTTP status code
- HTTP response headers
- 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:
- 1xx Informational
- 2xx Success
- 3xx Redirection
- 4xx Client Error
- 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
![](https://www.radiofree.org/wp-content/plugins/print-app/icon.jpg)
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/
Please log in to upload a file.
There are no updates yet.
Click the Upload button above to add an update.