Http Methods
# HTTP Request Methods
HTTP request methods define the communication mode between clients and servers.
According to HTTP standards, HTTP requests can use multiple request methods.
Here is a list of common HTTP request methods:
| No. | Method | Description |
| --- | --- | --- |
| 1 | GET | Retrieve resources from the server. Used to request data without making changes. For example, fetching web pages or images from the server. |
| 2 | POST | Send data to the server to create new resources. Commonly used for submitting form data or uploading files. The sent data is included in the request body. |
| 3 | PUT | Send data to the server to update existing resources. If the resource doesn't exist, it creates a new one. Unlike POST, PUT is usually idempotent, meaning multiple identical PUT requests won't produce different results. |
| 4 | DELETE | Delete specified resources from the server. The request contains the identifier of the resource to be deleted. |
| 5 | PATCH | Make partial modifications to resources. Similar to PUT but PATCH only changes part of the data rather than replacing the entire resource. |
| 6 | HEAD | Similar to GET, but the server only returns response headers without the actual data. Used to check resource metadata (e.g., verify resource existence, view response header information). |
| 7 | OPTIONS | Returns the HTTP methods supported by the server. Used to check which request methods the server supports, often used for CORS preflight requests. |
| 8 | TRACE | Echoes the request received by the server, mainly for diagnostics. Clients can view the processing path of the request in the server. |
| 9 | CONNECT | Establishes a tunnel to the server, typically used for HTTPS connections. Clients can send encrypted data through this tunnel. |
## Request Methods Defined by Each Version
### HTTP/1.0
HTTP/1.0 defines the following three request methods:
* **GET** - Request specified resources.
* **POST** - Submit data to process requests.
* **HEAD** - Request response header information for resources.
### HTTP/1.1
HTTP/1.1 introduced more methods:
* **GET** - Request specified resources.
* **POST** - Submit data to process requests.
* **HEAD** - Request response header information for resources.
* **PUT** - Upload files or update resources.
* **DELETE** - Delete specified resources.
* **OPTIONS** - Request supported methods from the server.
* **TRACE** - Echo received requests, mainly for diagnostics.
* **CONNECT** - Establish a tunnel for proxy server communication, typically used for HTTPS.
### HTTP/2
HTTP/2 essentially continues using HTTP/1.1 methods but optimizes the protocol to improve transmission efficiency and speed. HTTP/2 also introduces new features like multiplexing, header compression, and server push.
### HTTP/3
HTTP/3 is implemented based on the QUIC protocol and continues using HTTP/2 methods. HTTP/3 mainly improves the transport layer by using UDP instead of TCP to enhance transmission speed and reliability.
YouTip