Question: The teacher told Xiaoning that HTTP usually uses two request methods. Do you know which two methods they are?
Solution: Submit a=1 through get, and submit b=2 through post.
Related knowledge:
1. Get and post are two commonly used request methods in http.
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 cache |
encoding type | application/x-www-form-urlencoded | application/x-www-form-urlencoded or multipart/form-data. Use multiple encodings for binary data. |
history | Parameters are retained in browser history. | Parameters are not saved in browser history. |
Limitations 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 a URL is 2048 characters). | No restrictions. |
Restrictions on data types | Only ASCII characters are allowed. | no limit. Binary data is also allowed. |
safety | GET is less secure than POST because the data sent is part of the URL. Never use GET when sending passwords or other sensitive information! | POST is more secure than GET because parameters are not saved in browser history or web server logs. |
visibility | The data is visible to everyone in the URL. | The data will not be displayed in the URL. |
The following is a capture of the package to show the difference between get and post:
2. Other HTTP request methods
method | describe |
---|---|
HEAD | Same as GET, but only HTTP headers are returned, not the document body. |
PUT | Upload the specified URI representation. |
DELETE | Delete the specified resource. |
OPTIONS | Returns the HTTP methods supported by the server. |
CONNECT | Convert the requested connection to a transparent TCP/IP channel. |
The Chinese text of relevant knowledge comes from the novice tutorial.
https://www.runoob.com/tags/html-httpmethods.html