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
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 method names are case sensitive and they must be used in uppercase. The common HTTP methods are given bellow:
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:
HEAD method is as like as GET method. But it only transfer the status line and header section.
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 method Replace the current representations of the target resource with the uploaded content.
DELETE method remove current representations of the target resource.
CONNECT method establish a tunnel to the server identified by a given URI.
OPTIONS method describes the communication options for the target resource. it returns the HTTP methods that the server supports
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:
- It can be cached
- It remains in the browser history
- It can be bookmarked
- It is less secured
- It has length restrictions
- It should be used only to retrieve data
- It only allows ASCII characters
- It can’t be cached
- It does not remain in the browser history
- It can’t be bookmarked
- It is much secured than GET
- It has not any length restrictions
- It is used to send data to server
- It has no restriction. Binary data is also allowed
That’s all about HTTP methods.
4 thoughts on “HTTP Methods”
old, but very usefull. thanks for remembered