html5发送put或delete请求,PUT和DELETE HTTP请求方法的用处是什么?

DELETE用于删除请求资源:

The DELETE method requests that the origin server delete the resource identified by the Request-URI. This method MAY be overridden by human intervention (or other means) on the origin server. The client cannot be guaranteed that the operation has been carried out, even if the status code returned from the origin server indicates that the action has been completed successfully …

PUT用于放置或更新服务器上的资源:

The PUT method requests that the enclosed entity be stored under the supplied Request-URI. If the Request-URI refers to an already existing resource, the enclosed entity SHOULD be considered as a modified version of the one residing on the origin server. If the Request-URI does not point to an existing resource, and that URI is capable of being defined as a new resource by the requesting user agent, the origin server can create the resource with that URI …

完整规格参数:

POST http://example.com/order/1/delete

或甚至更糟

POST http://example.com/deleteOrder/id/1

有效地隧穿了通过HTTP的CRUD语义。但是动词从来不是URI的一部分。相反,HTTP已经通过HTTP方法向CRUD提供了资源(例如订单)的机制和语义。 HTTP是一种协议,而不仅仅是一些数据隧道服务。

因此,要删除网络服务器上的资源,您可以调用

DELETE http://example.com/order/1

并更新它,你会打电话

PUT http://example.com/order/1

并在PUT正文中提供更新的资源表示,供网络服务器应用。

所以,如果你正在为一个REST API构建某种客户端,你可能会发送PUT和DELETE请求。这可以是在浏览器内部构建的客户端,例如通过JavaScript发送请求,或者可以是在服务器上运行的某些工具等。

有关更多详情,请访问:

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值