取消的请求的正确HTTP状态代码是什么 [英] What is the Correct HTTP Status Code for a Cancelled Request

查看:317
本文介绍了取消的请求的正确HTTP状态代码是什么的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当客户端在发出HTTP请求时取消TCP连接时,我想停止在服务器上进行任何工作并返回空响应.这样的响应应该返回什么HTTP状态代码?

When a TCP connection gets cancelled by the client while making a HTTP request, I'd like to stop doing any work on the server and return an empty response. What HTTP status code should such a response return?

推荐答案

要保持一致,如果您的后端应用程序能够识别客户端何时断开连接,或者您拒绝或关闭连接,我现在建议400 Bad Request您可以返回Nginx的非标准代码499或444.

To be consistent I would suggest 400 Bad Request now if your backend apps are capable of identifying when the client gets disconnected or if you reject or close the connection, probably you could return Nginx' non-standard code 499 or 444.

  • 499个客户关闭请求 客户端在服务器发送响应之前关闭请求时使用.

  • 499 Client Closed Request Used when the client has closed the request before the server could send a response.

444无响应 用于指示服务器未向客户端返回任何信息并关闭连接.

444 No Response Used to indicate that the server has returned no information to the client and closed the connection.

这篇关于取消的请求的正确HTTP状态代码是什么的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆