补丁与放置 - 什么时候应该使用哪种方法?
Wikipedia说,PUT和PATCE之间的主要区别在于PUT从URI发送资源。因此,/model/id
。然后,补丁将在uri /model
上将数据发送到身体中以修改为键/值。
PUT和补丁方法之间的主要区别是PUT 方法使用请求URI提供了修改版本 请求的资源代替了原始版本的 资源,而补丁方法将一组说明提供给 修改资源。如果补丁文档大于 put方法发送的新版本然后 方法是首选。[1]
但是Wiki的含义是句子:“ 如果补丁文档大于PUT方法发送的资源的新版本,则PUT方法是可取的”。
Wikipedia says that the main difference between Put and Patch is that PUT sends the resource from the Uri. So /model/id
. Then Patch will send in the body the data to modify as key / value over the uri /model
.
The main difference between the PUT and PATCH method is that the PUT
method uses the request URI to supply a modified version of the
requested resource which replaces the original version of the
resource, whereas the PATCH method supplies a set of instructions to
modify the resource. If the PATCH document is larger than the size of
the new version of the resource sent by the PUT method then the PUT
method is preferred.[1]
But what does Wiki mean by the sentence: "If the PATCH document is larger than the new version of the resource sent by the PUT method, the PUT method is preferable".
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这意味着,如果一组指令的长度(用补丁提供)长于新资源的长度(提供的put),那么您也可以使用put。
我会说大部分时间都使用PUT,因为它更简单。也许您会将补丁用于大型资源,如果补丁说明很小。
It means that if the length of the set of instructions (supplied with PATCH) is longer than the length of the new resource (supplied with PUT) then you may as well just use PUT.
I would say most of the time just use PUT, as it's simpler. Maybe you would use PATCH for a large resource and if the PATCH instructions are small.
从我阅读的内容来看,在1/更多字段可能导致现有资源的破坏/损坏的情况下,使用放置而不是补丁可能是有用的。
因为在put中,我们发送了完整的有效负载,它将比我们要更新的字段具有更多的信息。
我们也可能有一个实现,如果某些字段引起可能带来不良后果的资源的更新,则说明。服务器可以返回带有消息的有效代码。
From what I have read, it may be useful to use PUT instead of PATCH in cases where update of 1/more fields might lead to break/corruption of existing resource.
Because in PUT we send the full payload and it will have more information than the fields that we want to update.
We may also have a implementation, wherein for PUT if some fields cause an update of the resource that may have ill consequences. The server can return a valid code with a message.