User-Agent: Mozilla / 4.0 (compatible; MSIE5.01; Windows NT)
Host: www.tutorialspoint.com
Accept-Language: en-us
Accept-Encoding: gzip, deflate
Connection: Keep-Alive
The server will respond to the above request as follows:
HTTP/1.1 200 OK Date: Mon, 27 Jul 2009 12:28:53 GMT Server: Apache/2.2.14 (Win32) Last-Modified: Wed, 22 Jul 2009 19:15:56 GMT ETag: "34aa387-d-1568eb00" Vary: Authorization,Accept Accept-Ranges: bytes Content-Length: 88 Content-Type: text/html Connection: Closed
Hello, World!
The HEAD method is similar to GET, except that the Server responds with one line and the Headers respond, but no object body. The following example shows the usage of the HEAD method to direct Header information to hello.htm :
HEAD /hello.htm HTTP / 1.1
User-Agent: Mozilla / 4.0 (compatible; MSIE5.01; Windows NT)
Host: www.tutorialspoint.com
Accept-Language: en-us
Accept-Encoding: gzip, deflate
Connection: Keep-Alive
The server responding to the HEAD above request is as follows:
HTTP / 1.1 200 OK
Date: Mon, 27 Jul 2009 12:28:53 GMT
Server: Apache / 2.2.14 (Win32)
Last-Modified: Wed, 22 Jul 2009 19:15:56 GMT
ETag: "34aa387-d-1568eb00"
Vary: Authorization, Accept
Accept-Ranges: bytes
Content-Length: 88
Content-Type: text / html
Connection: Closed
Note that here the Server does not send any data after the Header.
The POST method is used when you want to send some data to the Server, for example, updating files, sample data, etc. The following example shows the usage of the POST method to send a sample data to the Server, which will be processed by a process.cgi and finally a response will be returned:
POST /cgi-bin/process.cgi HTTP/1.1 User-Agent: Mozilla/4.0 (compatible; MSIE5.01; Windows NT) Host: www.tutorialspoint.com Content-Type: text/xml; charset=utf-8 Content-Length: 88 Accept-Language: en-us Accept-Encoding: gzip, deflate Connection: Keep-Alive
xml version = "1.0" encoding = "utf-8" ?>xmlns = "http://clearforest.com/" > string
On the Server side, scipt process.cgi processes the transmitted data and sends the following response:
HTTP/1.1 200 OK Date: Mon, 27 Jul 2009 12:28:53 GMT Server: Apache/2.2.14 (Win32) Last-Modified: Wed, 22 Jul 2009 19:15:56 GMT ETag: "34aa387-d-1568eb00" Vary: Authorization,Accept Accept-Ranges: bytes Content-Length: 88 Content-Type: text/html Connection: Closed
Request Processed Successfully
The PUT method is used to request the Server to keep the object body included in a location specified by the URL provided. The following example requires Server to save the object body provided in hello.htm at the root of the Server:
PUT /hello.htm HTTP/1.1 User-Agent: Mozilla/4.0 (compatible; MSIE5.01; Windows NT) Host: www.tutorialspoint.com Accept-Language: en-us Connection: Keep-Alive Content-type: text/html Content-Length: 182
Hello, World!
The server will save the object body in hello.jsp file and will send the following response back to the Client:
HTTP/1.1 201 Created Date: Mon, 27 Jul 2009 12:28:53 GMT Server: Apache/2.2.14 (Win32) Content-type: text/html Content-length: 30 Connection: Closed
The file was created.
The DELETE method is used to request the server to delete a file at the location specified by the URL provided. The following example requires the Server to delete the file for hello.htm at the root of the Server:
DELETE /hello.htm HTTP / 1.1
User-Agent: Mozilla / 4.0 (compatible; MSIE5.01; Windows NT)
Host: www.tutorialspoint.com
Accept-Language: en-us
Connection: Keep-Alive
The server will delete a mentioned file and will send the response back to the Client:
HTTP/1.1 200 OK Date: Mon, 27 Jul 2009 12:28:53 GMT Server: Apache/2.2.14 (Win32) Content-type: text/html Content-length: 30 Connection: Closed
URL deleted.
The CONNECT method is used by the Client to establish a network connection to the Server via HTTP. The following example requires a connection to a Server running on the host tutorialspoint.com :
CONNECT www.tutorialspoint.com HTTP / 1.1
User-Agent: Mozilla / 4.0 (compatible; MSIE5.01; Windows NT)
The connection is established with the Server and the following response is sent back to the Client:
HTTP / 1.1 200 Connection established
Date: Mon, 27 Jul 2009 12:28:53 GMT
Server: Apache / 2.2.14 (Win32)
The OPTIONS method is used by the Client to find HTTP methods and functions supported by a Server. The client can define a URL with the OPTIONS method or a * to target the entire Server. The following example requires a list of methods supported by a Server running on tutorialspoint.com:
OPTIONS * HTTP / 1.1
User-Agent: Mozilla / 4.0 (compatible; MSIE5.01; Windows NT)
The server sends an information based on the server's current configuration, for example:
HTTP / 1.1 200 OK
Date: Mon, 27 Jul 2009 12:28:53 GMT
Server: Apache / 2.2.14 (Win32)
Allow: GET, HEAD, POST, OPTIONS, TRACE
Content-Type: httpd / unix-directory
The TRACE method is used to map the contents of an HTTP request to the requester that can be used for the purpose of debugging at the time of development. The following example shows how to use the TRACE method:
TRACE / HTTP / 1.1
Host: www.tutorialspoint.com
User-Agent: Mozilla / 4.0 (compatible; MSIE5.01; Windows NT)
The server will send the following message in response to the above request:
HTTP / 1.1 200 OK
Date: Mon, 27 Jul 2009 12:28:53 GMT
Server: Apache / 2.2.14 (Win32)
Connection: close
Content-Type: message / http
Content-Length: 39
TRACE / HTTP / 1.1
Host: www.tutorialspoint.com
User-Agent: Mozilla / 4.0 (compatible; MSIE5.01; Windows NT)
According to Tutorialspoint
Previous post: Feedback (Response) in HTTP
Next article: Encrypt status in HTTP