Get the App
SLTechnology News&Howtos  ›  Internet Technology  › 

Request method of HTTP

Shulou Source: shulou.com Published: 2022-06-03 06:49:31 09月23日 Update

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.

Tags: Server resource service security data file method same scenario result check danger necessity action danger situation security entity substance common use Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Docker MySQL NVidia Redmi MariaDB