HTTP verbs list
Below is a list of the verbs existing in the standard HTTP protocol
- GET: Retrieves the indicated resource. This is the method used when requesting the content of a web page, for example.
- HEAD: Similar to GET, but does not retrieve the response body, only the header metadata.
- POST: Adds data to the server. It is always a creation method.
- PUT: A request to store the supplied entity at the specified URI. If the entity does not exist, it is created. If the entity exists, it is updated.
- DELETE: Removes the indicated resource.
- TRACE: Will return the same information that was sent in the request. It is a kind of echo. It is used to check whether the request has been modified by intermediate servers.
- OPTIONS: Returns the HTTP methods supported by the server for the specified URL.
- CONNECT: Converts the request into a TCP/IP tunnel. Usually used to establish HTTPS communications through unencrypted HTTP proxies.
- PATCH: Applies partial modifications to the specified resource.
Safe Methods
GET, HEAD, OPTIONS, and TRACE are considered safe methods as they do not alter or cause changes on the server.
Idempotent Methods
A method is considered idempotent when repeating the action has no repercussions on the server. PUT and DELETE are considered idempotent, as the same PUT request can be executed multiple times without any changes compared to the first execution. The same is true for DELETE. GET, HEAD, OPTIONS, and TRACE can also be considered idempotent as they can be executed multiple times without affecting the server's data.
POST is not considered idempotent, as repeating this method will create as many resources as there are executions.
Summary of HTTP Verbs or Methods
Verb | Request Body | Response Body | Safe | Idempotent | Cacheable |
---|---|---|---|---|---|
GET | X | X | X | X | |
HEAD | X | X | X | ||
POST | X | X | X | ||
PUT | X | X | X | ||
DELETE | X | X | |||
CONNECT | X | X | |||
OPTIONS | Optional | X | X | X | |
TRACE |