当聊天室中的用户没有空 space 时,服务器的适当响应状态代码是什么?

what is appropriate response status code from server when there is no empty space for user in chat room?

我正在使用 node.js koa 构建一个聊天应用程序。 聊天室的基本规则是有用户加入数量限制,(是PUT要求) 我正在努力向客户端提供适当的响应状态代码。

我已经查看了一些文件,这里是我找到的一些候选人。

400 bad request 422 Unprocessable entity 403 forbidden

400 bad request中,实际上这不是来自客户的错误请求。客户端遵守客户端-服务器之间的规则。 当谈到 422 Unprocessable entity 时,当数据库中不存在数据时看起来更有意义,这不是我的情况。

如果你熟悉建筑休息api,请你给我一些建议。

状态代码是 transfer of documents over a network 域中的元数据。它们用于允许通用组件正确解释响应消息并根据响应消息采取行动。

也就是说,您需要考虑文档级别发生的事情,而不是您的专业领域中的含义(“HTTP 是一种应用程序协议,但它不是 您的 应用程序协议" -- Webber, 2011).

403禁止即可

409 Conflict也可以。

422 Unprocessible Entity isn't quite right, based on your description. 422 是“这对我来说没有任何意义”,而不是“我现在不能那样做”。

The 422 (Unprocessable Entity) status code means the server understands the content type of the request entity (hence a 415(Unsupported Media Type) status code is inappropriate), and the syntax of the request entity is correct (thus a 400 (Bad Request) status code is inappropriate) but was unable to process the contained instructions. For example, this error condition may occur if an XML request body contains well-formed (i.e., syntactically correct), but semantically erroneous, XML instructions.