π GET
π POST
π PUT
π DELETE
π HEAD
π PATCH
π CONNECT
π OPTIONS
π TRACE
HTTP request methods are client-side actions that are initiated to perform specific actions.
They may not all be used on a daily basis, but they are useful to know. Let’s take a closer look at what they do.
π πππ
The GET method requests a representation of the specified resource from the server.
GET requests should only be used to request data (not to include data).
Consider when you are browsing LinkedIn, you can see various posts, the initial data is generally retrieved on GET requests.
π ππππ
The POST method is used to send data to the server. The Content-Type header specifies the type of the request’s body.
Think of when you fill out a contact form and click the submit button, the data is sent across via a POST request.
π πππ
The PUT request method either creates a new resource or replaces the target resource’s representation with the request payload.
The difference between PUT and POST is that PUT is idempotent: calling it once or several times successively has the same effect (no side effects), whereas consecutive identical POST requests may have additional effects, similar to placing an order multiple times.
π ππππππ
The DELETE request method removes the specified resource from the server.
Think about if you ever deleted a picture from social media; when it is truly deleted, it will be over a DELETE request.
π ππππ
The HEAD method requests the headers that would be returned if the URL of the HEAD request had been requested with the HTTP GET method instead.
For example, if a URL is likely to result in a large download, a HEAD request could read its Content-Length header to determine the file size without downloading the file.
π πππππ
The PATCH request method makes partial changes to a resource.
π πππππππ
The CONNECT method initiates two-way communication with the resource requested. It has the ability to open a tunnel.
The CONNECT method, for example, can be used to connect to websites that use SSL (HTTPS). The client requests that the TCP connection be tunneled through an HTTP Proxy server to the desired destination. The server then makes the connection on the client’s behalf. Once the server has established the connection, the Proxy server will continue to proxy the TCP stream to and from the client.
π πππππππ
The OPTIONS method requests communication options for a specific URL or server. With this method, a client can specify a URL or an asterisk (*) to refer to the entire server.
π πππππ
The TRACE method performs a message loop-back test along the path to the target resource. This can useful when it comes to debugging.