What is HTTP? Hypertext Transfer Protocol (Hypertext Transfer Protocol-HTTP) is a protocol designed to enable clients and servers to communicate smoothly. HTTP works with Request-response protocol (Request-reply protocol) between the client and the server. Get-gets data from the specified server post-submits data to the specified server to handle the GET method: When using the Get method, the query string (key-value pair) is appended to the URL address and sent to the server:/test/demo_form.jsp?name1= Value1&name2=value2 Features:
- Get requests can be cached
- Get requests are saved in the browser's browsing history
- URL with Get request can be saved as browser bookmark
- Get request has a length limit
- Get requests are primarily used to
Post method: When using the Post method, the query string exists separately in the post message and is sent to the server with the HTTP request: post/test/demo_form.jsp http/1.1host:w3schools.comname1= Value1&name2=value2 Features:
- Post requests cannot be cached
- Post requests are not saved in browser browsing history
- The URL to post request cannot be saved as a browser bookmark
- POST request has no length limit
The difference between get and post:
|
GE |
POST |
Click the Back/Refresh button |
No impact |
The data will be resent (the browser will prompt the user "data is being resubmitted") |
Add Bookmark |
OK |
No |
Cache |
OK |
No |
Encoding type (Encoding type) |
application/x-www-form-urlencoded |
Application/x-www-form-urlencoded or Multipart/form-data. Please use multipart encoding for binary data |
Historical records |
The parameters remain in the browser history. |
Parameters are not persisted in the browser history. |
Length limit |
When data is sent, the GET method adds data to the URL, and the length of the URL is limited (the maximum length of the URL is 2048 characters). Yes |
No |
Data type Restrictions |
Only ASCII character types are allowed |
There is no limit. Allows binary data |
Security |
The query string is displayed in the URL of the address bar and is not secure, please do not submit sensitive data using GET requests |
Since the data is not displayed in the address bar and is not cached or saved in the browsing history, it is safer to look at the post than the GET request, but it is not the safest way. If you need to transfer sensitive data, use encrypted mode to transfer |
Visibility of |
The query string is displayed in the URL of the address bar, visible |
The query string is not displayed in the Address bar, not visible |
Other HTTP request methods
Way |
Describe |
HEAD |
Similar to get requests, unlike a server that only returns HTTP header information, no page content |
PUT |
Upload a description of the specified URL |
DELETE |
Delete a specified resource |
OPTIONS |
Returns the HTTP methods supported by the server |
CONNECT |
Connection request converted to transparent TCP/IP tunneling |
HTTP Request mode: Get and post comparisons when sending data, the Get method adds data to the URL, and the length of the URL is limited (the maximum length of the URL is 2048 characters).