服务器应该针对我特定的情况返回哪个HTTP代码?

huangapple go评论65阅读模式
英文:

Which HTTP code should the server return for my particular case?

问题

我拥有的情景是:

用户1想要在服务器上编辑一些数据,于是他发送了一个请求以锁定这些数据以进行编辑。

假设,用户1想要编辑并尝试锁定的数据已经被用户2锁定,并且用户2正在进行编辑。

我应该如何通知用户1,服务器必须拒绝他的请求,并且暂时不允许用户1进行任何编辑?

我认为,服务器应该返回4xx客户端错误,但我对具体应该返回哪种错误码不太确定。
可能应该是 403 禁止访问

英文:

The scenario that I have:

User 1 wants to edit some data on the server, and he sends a request to lock the data for editing.

Assume, that the data that User 1 wants to edit and trying to lock already locked by User 2 and User 2 is doing editing now.

How should I notify User 1 that the server has to reject his request and doesn't allow any editing for User 1 for now?

I believe, that the server should return 4xx client error, but I am not sure with one exactly.
Possible it should be 403 Forbidden?

答案1

得分: 1

我会使用 HTTP 状态码 409。在此处查看更多详细信息:https://httpstatuses.com/409

英文:

I would use http code 409. Check it here for more details https://httpstatuses.com/409

答案2

得分: 0

我将使用"409 Conflict"。它表示您的服务器状态已更改。

链接:https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/409

英文:

I will use a "409 Conflict". It indicates that the state of your server has changed.

https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/409

答案3

得分: 0

我认为它一定会返回“423 Locked”:所访问的资源被锁定。

英文:

I think it must return "423 Locked": The resource that is being accessed is locked.

huangapple
  • 本文由 发表于 2020年10月6日 05:34:53
  • 转载请务必保留本文链接:https://go.coder-hub.com/64216502.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定