Netty服务器如何取消接收来自Web服务器的响应?
有人知道Netty服务器处理程序取消从Web服务器接收数据的最佳方法吗?我有一个将HttpRequests代理到Web服务器的服务器处理程序.但是,当发出请求的客户端取消请求时,我想停止从Web服务器接收服务器通道上的数据,而不关闭服务器处理程序和Web服务器之间的连接.
Does anyone know the best way for a netty server handler to cancel receiving data from a web server? I have a server handler which proxies HttpRequests to a web server. However, when the requesting client cancels the request, I would like to stop receiving data on my server channel from the web server without closing the connection between the server handler and the web server.
有人知道我该怎么做.非常感谢您的回复.
Does anyone know how I can go about doing this. Your response would be much appreciated.
谢谢!
您可以调用channel.config().setAutoRead(false)
,这将告诉netty停止从Channel
读取.一旦您想再次开始阅读,只需调用channel.config().setAutoRead(false)
.
You could call channel.config().setAutoRead(false)
this will tell netty to stop reading from the Channel
. Once you want to start reading again just call channel.config().setAutoRead(false)
.