HTTP Request Methods
HTTP request methods define the way clients and servers communicate.
According to the HTTP standard, HTTP requests can use various request methods.
The following is a list of common HTTP request methods:
| No. | Method | Description |
|---|---|---|
| 1 | GET | Retrieve a resource from the server. Used to request data without changing it. For example, fetching a web page or image from the server. |
| 2 | POST | Send data to the server to create a new resource. Commonly used to submit form data or upload files. The sent data is included in the request body. |
| 3 | PUT | Send data to the server to update an existing resource. If the resource does not exist, a new one is created. Unlike POST, PUT is usually idempotent, meaning repeated identical PUT requests produce the same result. |
| 4 | DELETE | Delete the specified resource from the server. The request includes the identifier of the resource to delete. |
| 5 | PATCH | Partially modify a resource. Similar to PUT, but PATCH changes only part of the data rather than replacing the entire resource. |
| 6 | HEAD | Similar to GET, but the server returns only the response headers, not the actual data. Used to check a resource's metadata (for example, to check whether a resource exists or to view the response header information). |
| 7 | OPTIONS | Return the HTTP methods supported by the server. Used to check which request methods the server supports, often for Cross-Origin Resource Sharing (CORS) preflight requests. |
| 8 | TRACE | Echo the request received by the server, mainly used for diagnostics. The client can see the path the request took through the server. |
| 9 | CONNECT | Establish a tunnel to the server, usually used for HTTPS connections. The client can send encrypted data through the tunnel. |
Request methods defined by each version
HTTP/1.0
HTTP/1.0 defined the following three request methods:
- GET Request the specified resource.
- POST Submit data to process the request.
- HEAD Request the response header information of the resource.
HTTP/1.1
HTTP/1.1 introduced more methods:
- GET Request the specified resource.
- POST Submit data to process the request.
- HEAD Request the response header information of the resource.
- PUT Upload a file or update a resource.
- DELETE Delete the specified resource.
- OPTIONS Request the supported request methods from the server.
- TRACE Echo the request received by the server, mainly used for diagnostics.
- CONNECT Establish a tunnel for proxy server communication, usually used for HTTPS.
HTTP/2
HTTP/2 basically adopted the methods of HTTP/1.1 but optimized the protocol, improving transmission efficiency and speed. HTTP/2 also introduced new features such as multiplexing, header compression, and server push.
HTTP/3
HTTP/3 is implemented based on the QUIC protocol and continues to use the methods of HTTP/2. HTTP/3 mainly improves the transport layer by using UDP instead of TCP to increase transmission speed and reliability.