HTTP Request Methods
HTTP request methods define how communication occurs between a client and a server. According to the HTTP standards, there are various request methods that can be used in HTTP requests. Here is a list of common HTTP request methods:
Common HTTP Request Methods
-
GET: Retrieves resources from the server. It is used to request data without making any changes to it. For example, fetching a webpage or an image from the server.
-
POST: Sends data to the server to create a new resource. It is commonly used to submit form data or upload files. The data sent is included in the request body.
-
PUT: Sends 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 multiple identical PUT requests will have the same effect as a single request.
-
DELETE: Deletes the specified resource from the server. The request includes the identifier of the resource to be deleted.
-
PATCH: Partially modifies a resource. Similar to PUT, but PATCH only changes part of the data instead of replacing the entire resource.
-
HEAD: Similar to GET, but the server only returns the headers in the response, not the actual data. It is used to check the metadata of a resource, such as verifying its existence or inspecting response headers.
-
OPTIONS: Returns the HTTP methods that the server supports. It is used to check which request methods are supported by the server, often used for Cross-Origin Resource Sharing (CORS) preflight requests.
-
TRACE: Echoes the received request, primarily used for diagnostics. The client can see the request path on the server.
-
CONNECT: Establishes a tunnel to the server, usually for HTTPS connections. The client can send encrypted data through this tunnel.
HTTP Request Methods Defined by Versions
HTTP/1.0
HTTP/1.0 defined the following three request methods:
- GET: Requests the specified resource.
- POST: Submits data to process a request.
- HEAD: Requests the headers of a resource's response.
HTTP/1.1
HTTP/1.1 introduced additional methods:
- GET: Requests the specified resource.
- POST: Submits data to process a request.
- HEAD: Requests the headers of a resource's response.
- PUT: Uploads a file or updates a resource.
- DELETE: Deletes the specified resource.
- OPTIONS: Requests the supported methods of the server.
- TRACE: Echoes the received request for diagnostics.
- CONNECT: Establishes a tunnel for communication with a proxy server, typically for HTTPS.
HTTP/2
HTTP/2 largely retained the methods from HTTP/1.1 but optimized the protocol to enhance transmission efficiency and speed. It also introduced new features like multiplexing, header compression, and server push.
HTTP/3
HTTP/3 is implemented based on the QUIC protocol and continues to use the methods from HTTP/2. HTTP/3 mainly improves the transport layer by using UDP instead of TCP to increase transmission speed and reliability.