Everything You Need to Know About HTTP (Hypertext Transfer Protocol)
HTTP (Hypertext Transfer Protocol) is the underlying protocol used by the World Wide Web that defines how messages are formatted and transmitted. Learn its purpose and main components, and understand its inner functions.
HTTP stands for Hypertext Transfer Protocol. It's the standard protocol that defines how messages are formatted and sent across the web.
The team at CERN, with Tim Berners-Lee as the lead, is known for inventing the original HTTP, as well as HTML. Tim Berners-Lee was also the person who first proposed the "WorldWideWeb" project back in 1989.
The first version of HTTP had one method that was then named GET. The GET method was used to request a page from a server and the server always responded with an HTML page.
HTTP today is used to deliver all kinds of content, including images, videos, documents, audios, etc.
In a sense, HTTP acts as a messenger of the web. It delivers messages from the client to the server, and vice versa.
Clients and servers are the two main players on the Internet.
The client is the computer that makes the request. This role is performed by the web browser such as Google Chrome or Safari.
The server is on the other side of the communication flow. The server's job is to serve the document the client requested.
Let's explain the process:
- You open your laptop and click on a browser, let's say Google Chrome. This is you accessing the Internet through a web client.
- You send a request to a web server to access a page.
- The server receives the request.
- The server responds.
This kind of relationship happens every time you click on a link.
HTTP is connectionless
"HTTP is connectionless" means that after making the request, the client disconnects from the server. When the response is ready, the connection reestablishes to deliver the response. Then it closes again.
HTTP is stateless
"HTTP is stateless" means that the client and the server are only aware of each other during a current request. After the request is completed, they forget about each other. If the two computers want to connect again, they will need to provide information about each other anew. The second connection will be handled in the same way as the first one.
HTTP can deliver any kind of data
As long as the two computers know how to handle it, HTTP can deliver any sort of data.
The purpose of HTTP is to fetch the resources a client requests.
Here's an example of the request-response cycle between a client and a server:
- The client and the server computers must be connected via an Internet connection.
- When the connection is established, the client requests to access a resource via an HTTP message.
- As HTTP is a connectionless protocol, the client disconnects from the server, waiting for a response.
- The server processes the request. It prepares the response, reestablishes the connection, and sends back the response via an HTTP message.
- The client receives the message.
- The two computers disconnect.
If we use human language to explain the process, it would go something like this:
- You: I want to see your Customer Service page.
- The server: Okay, got it. It's coming right away.
Or, if there's an error:
- You: I want to see your Customer Service page.
- The server: I'm sorry, I can not find the page you're requesting.
HTTP messages are sent in a format that's similar to the format used by the Internet mail and the Multipurpose Internet Mail Extensions.
A typical HTTP message has three main sections: the start line, the headers, and the body. Generally, the three sections are plain text and are easy to read.
The information of the HTTP message varies, depending on whether it's a request or a response.
Requests consist of the following elements:
- the HTTP method that tells the server what to do, usually a verb like GET or POST
- the URL of the resource stripped from elements that are obvious from the context
- the version of the HTTP protocol
- optional headers
Responses consist of the following elements:
- the version of the HTTP protocol
- a status code, such as a redirect, client error, or server error
- a status message that contains a short description of the status code
- HTTP headers
- a body containing the fetched resource, but this is optional
HTTP response status codes are contained in the HTTP message that's sent from the server to the client. They tell whether an HTTP request has been successfully completed or there was some type of error.
There are five main classes:
- 1xx: Informational responses
- 2xx: Successful responses
- 3xx: Redirects
- 4xx: Client errors
- 5xx: Server errors
1xx: Informational responses
The 1xx status codes indicate that the server has accepted the request, but is still processing it.
2xx: Successful responses
The 2xx status codes indicate that the server accepted the client's request to access a resource.
The most common 2xx status codes include:
- 200 OK
- 201 Created
- 202 Accepted
- 203 Non-Authoritative Information
- 204 No Content
- 205 Reset Content
- 206 Partial Content
- 207 Multi-Status
The 3xx HTTP status codes are redirection codes. They redirect users and search engines to a different URL from the one initially requested.
The most common 3xx status codes are:
- 300 Multiple Choices
- 301 Moved Permanently
- 302 Found
- 303 See Other
- 304 Not Modified
- 305 Use Proxy
4xx: Client errors
The 4xx status codes are client errors. Something on the client-side is the issue.
The most common client errors are:
- 400 Bad Request
- 403 Forbidden
- 404 Not Found
- 410 Gone
5xx: Server errors
The 5xx HTTP status codes are server errors. They indicate they something on the server-side is the problem.
The most common 5xx server errors include:
- 500 Internal Server Error
- 501 Not Implemented
- 502 Bad Gateway
- 503 Service Unavailable
- 504 Gateway Timeout
If you want to understand status codes more profoundly, we've prepared a comprehensive status codes cheat sheet. Use it to improve your website's future performance and create a better user experience for your visitors.
If HTTP stood for Hypertext Transfer Protocol, HTTPs stands for Hypertext Transfer Protocol Secure.
Some URLs start with "HTTP," and others with "HTTPS." The "s" stands for "secure encryption," which is guaranteed with a certificate.
HTTPS uses a public key that is decrypted on the recipient's side. The public key is included in an SSL certificate.
An SSL certificate is like an online ID card that says: this website is protected and secure from outside threats. Your information is safe here.
Websites that collect people's sensitive information, including home addresses and credit card numbers, must purchase an SSL license.
SSL encryption comes with many benefits, both for customers and websites. The top benefits include:
- Safety from hackers: as the certificate protects sensitive information, hackers and identity thieves will have to take their business elsewhere.
- Authenticity and trustworthiness: people want to do business with a website that's secure and trustworthy. They won't make a purchase on websites that aren't verified and encrypted.
- A boost in Google search rankings: in 2014, Google said a certificate installed on your website would increase your ranking position.
- Increased conversion rate: one study by Symantec showed that protected eCommerce websites have an 18-87% increase in conversion rate.
- Increased value per transaction: customers hesitate to spend a large amount of money on a transaction if they don't trust the website. One case study by Comodo found that a digital certificate installed can increase the average value per transaction by 23%.
To sum up, the main things we can learn from this article are:
- HTTP stands for Hypertext Transfer Protocol. It's the standard protocol that defines how messages are formatted and sent across the web.
- In a sense, HTTP acts as a messenger of the web. It delivers messages from the client to the server, and vice versa.
- The three important aspects of HTTP is that it is connectionless, stateless, and can deliver any kind of data.
- The purpose of HTTP is to fetch the resources a client requests.
- A typical HTTP message has three main sections: the start line, the headers, and the body.
- There are different types of HTTP response status codes. They all indicate whether a specific HTTP request has been successfully completed. There are five classes, including 1xx, 2xx, 3xx, 4xx, and 5xx status codes.
If HTTP stood for Hypertext Transfer Protocol, HTTPs stands for Hypertext Transfer Protocol Secure. The difference is that HTTPS transmits its data security using an encrypted connection.