HTTP Methods
For HTTP/1.1, the set of common methods are defined below. This set can be expanded based on the requirements. The name of these methods is case sensitive, and they must be used in uppercase.
Method and Description
i) GET
This method retrieves information from the given server using a given URI. GET request can retrieve the data. It can not apply other effects on the data.
ii) HEAD
This method is the same as the GET method. It is used to transfer the status line and header section only.
iii) POST
The POST request sends the data to the server. For example, file upload, customer information, etc. using the HTML forms.
iv) PUT
The PUT method is used to replace all the current representations of the target resource with the uploaded content.
v) DELETE
The DELETE method is used to remove all the current representations of the target resource, which is given by URI.
vi) CONNECT
This method establishes a tunnel to the server, which is identified by a given URI.
vii) OPTIONS
This method describes the options of communication for the target resource.
GET Method
This method is used to retrieve data from a web server using the specifying parameters in the URL portion of the request. This is the main method that is used for document retrieval. The use of the GET method to fetch first.htm is as follows:
The following are the server response against the above GET request:
HEAD Method
This method is the same as the GET method. But in the HEAD method, the server replies with a response line and headers without entity-body. The use of HEAD method to fetch header information about first.htm is as follows:
The following are the server response against the above HEAD request:
Here, we can see that the server does not send any data after the header.
POST Method
This method is used to send some data to the server, for example, update files from data, etc. The use of POST method to send a form data to the server is as follows:
The script of server side process.cgi processes the passed data and sends the response which is as follows:
PUT Method
This method requests the server to store the included entity-body at a location that is specified by the given URL. The below example requests the server to save the given entity-body in first.htm at the root of the server.
In first.htm file, the server will store the given entity-body, and it will also send the following response back to the client:
DELETE Method
This method requests the server to delete a file at a location that is specified by the given URL. The below example requests the server to delete the first.htm file at the root of the server:
After the above example, the server will delete the first.htm file, and it will also send the response back to the client, which is as follows:
CONNECT Method
This method is used by the client. It establishes a network connection to a web server over HTTP. The below example requests a connection with a web server which is running on the host javatpoint.com:
The following example shows that the connection is established with the server, and the response is sent back to the client:
OPTIONS Method
This method is used by the client. It is used to find out the HTTP methods and other options that are supported by a web server. The below example requests a list of methods which is supported by a web server which is running on javatpoint.com:
In the below example, the server will send information which is based on the current configuration of the server:
0 Comments