Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Request method of HTTP

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/03 Report--

Common methods:

Get

Head

The server does not return the requested entity data, only the response header.

You can think of it as a simplified version of the get method or a "lightweight version" because its response header is exactly the same as that of get.

It can be used in many situations where resources are not really needed to avoid the waste of transmitting body data.

Scenario 1: to check whether a file exists, just send a HEAD request, there is no need to use GET to remove the entire file.

Scenario 2: to check whether the file has the latest version, you should use HEAD, and the server will send back the modification time of the file in the response header.

Post

Put

If post is new, then put can be understood as modifying

Delete

Instructs the server to delete resources.

Because this action is too dangerous, the server usually does not perform a real delete operation, but instead makes a delete tag on the resource.

We can use the analogy of adding, deleting, changing and searching:

Insert:post

Delete:delete

Update:put

Select:get

Security:

The so-called "security" means that the request method will not "destroy" the resources on the server, that is, it will not cause substantial changes to the resources on the server.

Get and head are safe because they are read-only.

Post, put and delete are not safe.

Idempotent:

The result is "equal" after many times of "power". Perform the same operation many times, and the result is the same.

Get and head are idempotent.

Post is new every time, so it is not idempotent.

Put can be understood to mean that each modification is the same piece of data, so it is idempotent.

Delete can delete the same piece of data multiple times, and the effect is "resource does not exist", so it is also idempotent.

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.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report