HTTP Methods

HTTP is the basic protocol used by the World Wide Web or WWW. It describes how messages are formatted and transmitted, and what actions Web servers and Web browsers should take in response to various commands. HTTP uses some methods for communications. This article explains the methods used in HTTP. Summary of the article:

  • What is HTTP?
  • HTTP Methods
  • GET vs. POST

sql

What is HTTP?
The full meaning of HTTP is Hypertext Transfer Protocol. It is an application level protocol for distributed, hypermedia information systems. Since 1990 it is the foundation of data communication for the World Wide Web or internet. HTTP protocol is generic and stateless.
It works as a request/response protocol between a client and server. A web browser may be the client and a web site may be the server. A browser or client submits an HTTP request to the server. The server then returns a response to the client. The response contains the information of the request and may also contain the content.

HTTP Methods
HTTP method names are case sensitive and they must be used in uppercase. The common HTTP methods are given bellow:

  1. GET
  2. HEAD
  3. POST
  4. PUT
  5. DELETE
  6. CONNECT
  7. OPTIONS
  8. TRACE

GET Method
The GET method is used to retrieve information from the server using a URL. Requests using GET should only retrieve data and should have no other effect on the data. When we use a GET method, key and values append at the end of the URL as a query string. That means data will be visible in the page address. That’s why GET method is not recommended to use to pass sensitive data over the internet. The length of a URL is limited. Latest web browser support 2048 characters. For example consider the following URL:
[mypage.html?fname=John&lname=Abrar]

HEAD
HEAD method is as like as GET method. But it only transfer the status line and header section.

POST
POST method is used to send data to the server.(customer information, file upload etc using HTML forms). When we use a POST method, key and values not append at the end of the URL as a query string. Data is not visible in the page address. Generally POST method is used to pass sensitive data, updating data etc. There is no length limitation to send data.

PUT
PUT method Replace the current representations of the target resource with the uploaded content.

DELETE
DELETE method remove current representations of the target resource.

CONNECT
CONNECT method establish a tunnel to the server identified by a given URI.

OPTIONS
OPTIONS method describes the communication options for the target resource. it returns the HTTP methods that the server supports

TRACE
Perform a message loop-back test along the path to the target resource.

GET vs. POST
The difference between GET and POST methods in HTML forms are  given bellow:
GET

  1. It can be cached
  2. It remains in the browser history
  3. It can be bookmarked
  4. It is less secured
  5. It has length restrictions
  6. It should be used only to retrieve data
  7. It only allows ASCII characters

POST

  1. It can’t be cached
  2. It does not remain in the browser history
  3. It can’t be bookmarked
  4. It is much secured than GET
  5. It has not any length restrictions
  6. It is used to send data to server
  7. It has no restriction. Binary data is also allowed

That’s all about HTTP methods.

Comments

  1. By Anup kumar

    Reply

Leave a Reply

Your email address will not be published. Required fields are marked *