HTTP request method in rest mode (get,post,put,delete)

Source: Internet
Author: User

has been testing the rest mode of the Web service interface, the client's HTTP request generally divided into four kinds: GET, POST, PUT, DELETE, these four kinds of request how different. To put it simply, get is to get resources, post is to create resources, puts is to update resources, delete is to remove resources. Specifically:

The put:put request is to send data to the server to change the information, which, like the database update operation, modifies the contents of the data, but does not increase the type of data, that is, the resource does not increase regardless of the number of put operations.

The delete:delete request, as its name implies, is used to delete a resource, which is like a database delete operation.

The get:get operation is safe. Security means that no matter how many operations are performed, the state of the resource does not change, and get just accesses and views the resource.

Post: The operation is not secure, and each request creates a resource, and when we issue a POST request several times, the result is that multiple resources are created. Another thing to note is that the create operation can use post, or put, except that the post is acting on a collection resource (/uri), and the put operation is on a specific resource (/URI/XXX), and then, in a more popular sense, If the URL can be determined on the client, then use put, if it is determined on the server, then use post, for example, many resources use the database self-increment primary key as identity information, and the identity information of the created resource is what can only be provided by the server, this time must use post.

  Here's the difference between get and post:

1, GET request data will be appended to the URL (that is, the data placed in the HTTP protocol header), in order to split the URL and transfer data, the parameters are connected to &, such as: getcitycode?lat=100.22&lon=35.33

 Post submits the data to the packet in the HTTP packet.
2, on the browser, the Get method to submit data is limited, for example, sometimes the requested URL is too long, will return an error, but if it is a client get request, there is no data limit. Post has no limits and can be used to transmit a larger amount of data.
3, post security is higher than get security. The security described here is not the same concept as the "security" mentioned in get above. The meaning of "security" above is simply not to make data changes, and the meaning of security here is the meaning of true security, such as: submit data through get, user name and password will appear in plaintext on the URL, view the history of the browser, you can see the parameters of the GET request, such as the login account password, Search for keywords, personal information, and more.
  

HTTP request method in rest mode (get,post,put,delete)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.