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.