In this blog, we will see GET and POST method in details.
GET and POST are 2 important HTTP verbs. HTTP (Hyper Text Transfer Protocol) manage the request-response between client and server.
HTTP GET Method
- GET parameters included in URL
- Used for fetching resource i.e. data or documents
- In GET request we can send data in text format only.
- GET methods are Read-Only.
- State of application will not change
- GET has the limitation of maximum URL length. General limit is 2KB i.e. 2048 characters
- Request made through GET is cacheable
- Shouldn't make any changes to the server
- GET request is visible in URL so sensitive data like username and password cannot be sent via GET request.
- GET request is a safe request
- Typing a website URL in browser address bar and pressing enter is the default GET request.
- If a form tag in HTML page does not specify any method then by default it is a GET request.
- GET requests are Idempotent. It means whether you request single time or twice or n number of times the response will be same and there is no change at the server. These type of requests is known as an Idempotent method.
HTTP POST Method
- POST parameter included in the body
- Used for manipulating data i.e. updating a record or to make some changes on the server
- User's request will be encapsulated in the Request body
- POST doesn't have a max limit as it is encapsulated in the Body part. So we can send any amount of data to the server.
- Request made using POST is not cacheable
- POST request is not safe.
- POST is to make changes to the server
- POST request is not visible in URL
- POST can send Binary as well as Text data.
- POST request is Non-Idempotent. As response may change each request. For eg - Updating a record.