取消的请求的正确HTTP状态代码是什么

编程入门 行业动态 更新时间:2024-10-23 01:34:37
本文介绍了取消的请求的正确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状态代码是什么

本文发布于:2023-11-08 07:05:07,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1568681.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:正确   状态   代码   HTTP

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!