What is HTTP?
The Hypertext Transfer Protocol (HTTP) is designed to enable communications between clients and servers.
HTTP works as a request-response protocol between a client and server.
A web browser may be the client, and an application on a computer that hosts a web site may be the server.
A client (browser) submits an HTTP request to the server; then the server returns a response to the client. The response contains status information about the request and may also contain the requested content.
There are two HTTP request methods: GET and POST
- GET – Requests data from a specified resource.
- POST – Submits data to be processed to a specified resource.
The GET Method
In GET method the data is sent as URL parameters that are usually strings of name and value pairs separated by ampersands (&). In general, a URL with GET data will look like this:
- The bold parts in the URL are the GET parameters and the italic parts are the value of those parameters.
- More than one parameter=value can be embedded in the URL by concatenating with ampersands (&).
- One can only send simple text data via GET method.
Advantages of Using the GET Method
- Since the data sent by the GET method are displayed in the URL, it is possible to bookmark the page with specific query string values.
- GET requests can be cached and GET requests remain in the browser history.
- GET requests can be bookmarked.
Disadvantages of Using the GET Method
- The GET method is not suitable for passing sensitive information such as the username and password, because these are fully visible in the URL query string as well as potentially stored in the client browser’s memory as a visited page.
- Because the GET method assigns data to a server environment variable, the length of the URL is limited. So, there is a limitation for the total data to be sent.
The POST Method
In POST method the data is sent to the server as a package in a separate communication with the processing script. Data sent through POST method will not be visible in the URL.
POST /test/demo_form.php HTTP/1.1
The query string (name/weight) is sent in the HTTP message body of a POST request.
Advantages of using POST Method
- It is more secure than GET because user-entered information is never visible in the URL query string or in the server logs.
- There is a much larger limit on the amount of data that can be passed and one can send text data as well as binary data (uploading a file) using POST.
Disadvantages of using the POST Method
- Since the data sent by the POST method is not visible in the URL, so it is not possible to bookmark the page with specific query.
- POST requests are never cached
- POST requests do not remain in the browser history.
- How to select and upload multiple files with HTML and PHP, using HTTP POST?
- Get and Post method using Fetch API
- jQuery | post() Method
- How to receive JSON POST with PHP
- How to display bootstrap carousel with three post in each slide?
- Tracxn Experienced Interview (3yrs SSE post)
- Python | Automating Happy Birthday post on Facebook using Selenium
- HTTP | PUT
- HTTP headers | Age
- HTTP headers | Via
- HTTP headers | Range
- HTTP headers | X-XSS-Protection
- HTTP headers | Set-Cookie
- HTTP headers | Cookie
- HTTP headers | Retry-After
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.