英文:
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.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论