gpt4 book ai didi

c# - 当客户错过接受报价的机会时,应该使用什么 HTTP 响应代码

转载 作者:塔克拉玛干 更新时间:2023-11-01 19:08:17 25 4
gpt4 key购买 nike

我正在用 C# 编写 Web 应用程序。一个功能是服务器将发送推送通知,为客户端提供完成一轮工作的机会。客户可以接受或拒绝这项工作。

但是,如果客户端响应时间过长,服务器会将此视为隐式拒绝,并将该轮工作交给其他人。

这是服务器上 Controller 端点的摘录,客户端可以在其中发布它对当前回合的接受

public HttpResponseMessage PostAcceptRound(PersonData accepter){
Round currentRound = repo.GetCurrentRound();
if(currentRound.offeredTo.id == accepter.id){
repo.RoundAccepted(currentRound.id);
return Request.CreateResponse<String>(HttpStatusCode.OK, "Round has been accepted");
}
else{
//return appropriate response
}
}

我的问题是:对于接受时间过长的客户,什么是合适的回应?

我最初的 react 是我应该发送“BadRequest”错误响应。但是,迟到拒绝的人并不是不合时宜的要求或出乎意料的事情。事实上,似乎接受得太迟将是使用此应用程序时经常发生的情况。

最佳答案

408 = 'Request Timeout' 在我看来最合适。
http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html

关于c# - 当客户错过接受报价的机会时,应该使用什么 HTTP 响应代码,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27482406/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com