如果您发出 PUT 请求并且服务器上没有这样的实体怎么办?
What if you make a PUT request and there is no such entity on server?
如果您尝试更新服务器上的实体(发出 PUT
请求)但没有这样的实体会怎样?
服务器是否会创建实体或响应错误?
根据 HTTP/1.1 规范服务器 可以创建一个新实体:
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.
If a new resource is created, the origin server MUST inform the user agent via the 201 (Created) response.
如果您尝试更新服务器上的实体(发出 PUT
请求)但没有这样的实体会怎样?
服务器是否会创建实体或响应错误?
根据 HTTP/1.1 规范服务器 可以创建一个新实体:
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.
If a new resource is created, the origin server MUST inform the user agent via the 201 (Created) response.