The difference between "HTTP" get and post
HTTP defines different ways to interact with the server, with four basic methods: GET, POST, PUT, DELETE.
The URL is a resource descriptor that describes the resources on the web. The above four types of resources are the search, change, increase, delete operation.
"How is HTTP regulated?" 】
Get: Query/FETCH without affecting the state of the resource
POST: Updating resources
PUT: Add
DELETE: Deletion
"How is it used in practice?" 】
Get: Query/GET, modify resources
POST: Updating resources
PUT: Rarely used
DELETE: Rarely used
Get and post are not a one-to-one, but they are essentially a different sending mechanism.
Check and delete the action can be done by get/post way, do not need put and deleted
"What is the reason why the actual use is inconsistent with the specification?" 】
The reasons why put and delete are seldom used are:
The early web MVC Framework designers did not realise that URLs were viewed and designed as abstract resources.
So a more serious problem is that the traditional Web MVC framework basically supports only get and post two HTTP methods,
The put and delete methods are not supported.
"What is the difference between get and post?" 】
1. Where they are located
(1) Get in URL:
The data for the GET request is appended to the URL (that is, placing the data in the HTTP protocol header) to split the URL and transfer the data.
The parameters are connected to &, such as:
Login.action?name=hyddd&password=idontknow&verify=%e4%bd%a0%e5%a5%bd
If the data is an English letter/number, it is sent as-is, if it is a space, converted to
+, if it is a Chinese/other character, the string is directly encrypted with BASE64, which is obtained as follows:
%E4%BD%A0%E5%A5%BD, where xx in%xx is the ASCII of the symbol in 16 binary notation
(2) post is submitted via form, and the submitted data is placed in the package body of the HTTP package and is not explicitly rendered in the URL
2. Size limit
GET
(1) HTTP Specification: The HTTP specification does not specify the length limit of the URL, get data in the URL, so get the amount of data directly affect the length of the URL,
Therefore, the specification does not limit the amount of get data
(2) In practice: The limit is mainly the browser and server restrictions on it. IE's limit on URL length is 2083 bytes (2k+35). For other browsers,
such as Netscape, Firefox, etc., theoretically no length limit, its limitations depend on the operation system support.
POST
(1) HTTP specification: No limit on the size of post data
(2) In practice: Limitations are primarily the ability of the server to process data
3. Security
Post is more secure than get and is shown in:
(1) The Get data appears on the URL, because (1) the login page may be cached by the browser, (2) Other people view the browser's history,
Then someone else can get your account number and password.
(2) using get to submit data may cause Cross-site request forgery attack
Another
The method by which the form submits the data is the Get method
The difference between "HTTP" get and post