客户端关闭http请求,服务器为什么还会发送数据?

当客户端发送Fin关闭TCP连接时,仅关闭了客户端到服务器的数据传输方向。服务器未发送Fin,因此仍可继续向客户端发送数据,如HTTP响应。若要立即关闭双向连接,客户端应发送TCP Reset (Rst)而非Fin。
摘要由CSDN通过智能技术生成

参考

HTTP response after request cancellation
TCP协议详解

概况

tcp请求是双向的,客户端关闭了,不接受数据。但是服务端没有关闭,仍然会发送数据。

TCP connections are bi-directional, and a single Fin only closes one direction. When you cancelled your request on the client side, you sent a Fin and the server’s TCP stack Ack’d it, which confirms that the client-to-server direction is now closed. So it would be illegal for your client to send more data to the server on that connection now. But since the server never sent a Fin, the server-to-client direction is still open. So it’s legal for the server to continue to send data on that connection, which it does: the HTTP response.

If you wanted to force both directions closed immediately, you should have sent a TCP Reset (Rst) instead of a Fin.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值