English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
The two most commonly used HTTP methods are: GET and POST.
The design purpose of Hypertext Transfer Protocol (HTTP) is to ensure communication between client and server.
The way HTTP works is the request between client and server-Response protocol.
Web browsers may be clients, and network applications on computers may also act as server-side.
For example, the client (browser) submits an HTTP request to the server; the server returns a response to the client. The response contains status information about the request and possibly the content requested.
Request between client and server-The two most commonly used methods for responding are: GET and POST.
GET - Request data from the specified resource.
POST - Submit the data to be processed to the specified resource.
Please note, the query string (name/Pairs of values) are sent in the URL of the GET request:
/run/demo-form.php?name1=value1&name2=value2
Some other comments about GET requests:
GET requests can be cached
GET requests are retained in the browser history
GET requests can be bookmarked
GET requests should not be used when handling sensitive data
GET requests have length limits
GET requests should only be used to retrieve data
Please note, the query string (name/Pairs of values) are sent in the body of the HTTP message in POST requests:
POST /run/demo-form.php HTTP/1.1
Host: oldtoolbag.com
name1=value1&name2=value2
Some other comments about POST requests:
POST requests will not be cached
POST requests will not be retained in the browser history
POST cannot be bookmarked
There is no requirement for data length in POST requests
The following table compares the two HTTP methods: GET and POST.
GET | POST | |
---|---|---|
Back button/Refresh | Harmless | The data will be resubmitted (the browser should inform the user that the data will be resubmitted). |
Bookmark | Can be bookmarked | Cannot be bookmarked |
Cache | Can be cached | Cannot be cached |
Encoding type | application/x-www-form-urlencoded | application/x-www-form-urlencoded or multipart/form-data. Use multiple encodings for binary data. |
History | The parameters are retained in the browser history. | The parameters will not be saved in the browser history. |
Limitation on data length | Yes. When sending data, the GET method adds data to the URL; the length of the URL is limited (the maximum length of the URL is 2048 characters). | Unrestricted. |
Restrictions on data types | Only allows ASCII characters. | No restrictions. Also allows binary data. |
Security | Compared to POST, GET has poorer security because the data sent is part of the URL. Never use GET when sending passwords or other sensitive information! | POST is safer than GET because parameters are not saved in the browser history or web server logs. |
Visibility | Data in the URL is visible to everyone. | Data will not be displayed in the URL. |
The following table lists some other HTTP request methods:
Method | Description |
---|---|
HEAD | Same as GET, but only returns HTTP headers, not the document body. |
PUT | Upload the specified URI representation. |
DELETE | Delete the specified resource. |
OPTIONS | Return the HTTP methods supported by the server. |
CONNECT | Convert the request connection to a transparent TCP/IP Channel. |