HTTP (Hypertext Transfer Protocol) is the foundational protocol used for transferring data on the web. This document provides an overview of the basic concepts and principles behind HTTP.
What is HTTP?
HTTP is a protocol that defines how messages are formatted and transmitted, and what actions web servers and browsers should take in response to these messages. It is a request-response protocol, meaning that the client sends a request to the server, and the server sends back a response.
HTTP Methods
HTTP defines several methods (also known as verbs) that specify the action to be performed on the resource. The most common methods are:
- GET: Retrieve data from the server.
- POST: Send data to the server to create or update a resource.
- PUT: Update a resource on the server.
- DELETE: Remove a resource from the server.
HTTP Status Codes
HTTP status codes are three-digit numbers that indicate the result of the request made by the client. Here are some common status codes:
- 200 OK: The request was successful.
- 404 Not Found: The requested resource was not found on the server.
- 500 Internal Server Error: There was an error on the server while handling the request.
URL Structure
A URL (Uniform Resource Locator) is the address of a resource on the web. It typically consists of the following parts:
- Protocol: The protocol used to access the resource (e.g.,
http://
orhttps://
). - Domain Name: The name of the server hosting the resource.
- Port: The port number on which the server is listening.
- Path: The path to the resource on the server.
- Query String: Optional data passed to the server (e.g.,
?key=value
).
Example of an HTTP Request
GET /en/documentation HTTP/1.1
Host: www.example.com
In this example, the client is requesting the /en/documentation
resource from the server www.example.com
.