Word publishes to Blog Park: HTTP method: GET vs. POST
Http://www.w3school.com.cn/tags/html_ref_httpmethods.asp
The two most common HTTP methods are: GET and POST.
What is HTTP?
The Hypertext Transfer Protocol (HTTP) is designed to ensure communication between the client and the server.
HTTP works as a request-response protocol between the client and the server.
A Web browser might be a client, and a network application on a computer might be a server-side.
Example: the client (browser) submits an HTTP request to the server, and the server returns a response to the client. The response contains status information about the request and what might be requested.
Two methods of HTTP request: GET and POST
In the request-response between the client and the server, the two most commonly used methods are: GET and POST.
- GET-Requests data from the specified resource.
- POST-submits the data to be processed to the specified resource.
GET method
Note that the query string (name/value pair) is sent in the URL of the GET request:
/test/demo_form.asp?name1=value1&name2=value2
Some additional comments about the GET request:
- Get requests can be cached
- GET requests remain in browser history
- Get requests can be bookmark-Favorites
- GET requests should not be used when handling sensitive data
- Get request has a length limit
- GET requests should only be used to retrieve data
POST method
Note that the query string (name/value pair) is sent in the HTTP message body of the POST request:
Post/test/demo_form.asp http/1.1
Host:w3schools.com
Name1=value1&name2=value2
Some additional comments about the POST request:
- POST requests are not cached
- POST requests are not persisted in browser history
- POST cannot be bookmarked
- POST request has no requirement for data length
Compare GET to POST
The following table compares the two HTTP methods: GET and POST.
Compare target |
GET |
POST |
Back button/Refresh |
harmless |
The data is resubmitted (the browser should tell the user that the data will be resubmitted). |
bookmarks |
Favorites Bookmark |
not bookmark |
cache |
can be cached |
can't cache |
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 remain in the browser history. |
Parameters are not saved in the browser history. |
Limits on the length of data |
Yes, I do. When data is sent, the GET method adds data to the URL, andthe length of the URL is limited (the maximum length of the URL is 2048 characters). |
no restrictions. |
restrictions on data types |
allow only ASCII Character. |
no restrictions. Binary data is also allowed. |
Security |
GET is less secure than POST because the data being sent is part of the URL. Never use get! when sending passwords or other sensitive information |
post than GET More secure because parameters are not saved in the browser history or Web server logs. |
visibility |
data in URL are visible to all. |
data is not displayed in The URL. |
Other HTTP Request Methods
Some other HTTP request methods are listed in the following table:
Method |
Description |
head |
same as GET, However, only the HTTP header is returned and the document body is not returned. |
put |
upload the specified URI Said. |
delete |
delete the specified resource. |
options |
back to server supported HTTP method. |
CONNECT |
Convert the request connection to a transparent TCP/IP channel. |
http method: GET contrast POST "JAVA:SPRINGMVC: Basics: HTTP Protocol: 000 ()