In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-23 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Network Security >
Share
Shulou(Shulou.com)06/01 Report--
The standard Http protocol supports six request methods, namely:
1 、 GET
2 、 POST
3 、 PUT
4 、 Delete
5 、 HEAD
6 、 Options
But in fact, we only use GET and POST in most cases. If you want to design a web application that conforms to the RESTful specification, all six methods will be used. But even if you don't want to talk about REST for the time being, it's still useful to understand the nature of these six methods. You will find that web is also very concise and clear. The following six methods are described in turn.
The most common kind of get is to send a request to get a resource on the server. The resource is returned to the client through a set of HTTP headers and presentation data (such as HTML text, or pictures or videos, etc.). Rendering data is never included in the GET request.
2 HEAD head and GET are essentially the same, except that the head does not contain presentation data, but only contains the header information. Some people may think that this method is useless, but in fact this is not the case. Imagine a business scenario: to determine whether a resource exists, we usually use GET, but here the meaning of using HEAD is clearer.
3Gore put: this method is rare. HTML forms don't support this either. In essence, PUT and POST are very similar, both send data to the server, but there is an important difference between them. PUT usually specifies the location of resources, while POST does not, and the location of POST data is determined by the server itself.
For example: an URL,/addBlog used to submit a blog post. If you use PUT, the submitted URL will be "/ addBlog/abc123" like this, where abc123 is the address of the blog post. If POST is used, the address will be notified to the client by the server after it is submitted. At present, most blogs are like this. Obviously, PUT and POST are used for different purposes. Which one to use also depends on the current business scenario.
4Delete: delete a resource. Basically, this is rare, but there are still some places, such as the method used in amazon's S3 cloud service, to delete resources.
5Jing post: submit data to the server. This method has a wide range of uses, and almost all submission operations currently depend on it.
6Gramming options: this method is interesting, but rarely used. It is used to get the methods supported by the current URL. If the request is successful, it contains a header named "Allow" in the HTTP header, and the value is the supported method, such as "GET, POST".
In fact, there is also a TRACE method, but this basically will not be used, so I will not introduce it here.
For the above six methods, we can correspond to the CRUD addition, deletion, modification and query operations of the database:
CREATE: PUT
READ:GET
UPDATE:POST
DELETE:DELETE
In this way, it realizes the perfect unity of HTTP and database operation (not only the database, but any data such as files and charts), which is also one of the quintessence of REST.
Original address: http://blog.csdn.net/themagickeyjianan/article/details/71404724
-
III. The difference between PUT and POST
1. When PUT requests, if you access the secondary interface with the same parameters, PUT will only generate one record.
Use occasions such as:
The QR code of the user's account is only associated with the user, and there is an one-to-one correspondence. In this case, the api can be used with PUT.
2. When POST requests, if you access the secondary interface with the same parameters, Post will generate multiple records.
Use occasions such as:
In our payment system, the function of an api is to create a collection amount QR code, which is related to the amount. Each user can have multiple QR codes. If the QR code is called continuously, a new QR code will be created. Use POST at this time.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.