开发者

How can I change the socket timeout for a half-processed request in Apache httpcore NIO?

开发者 https://www.devze.com 2023-03-12 17:22 出处:网络
Say you have an application based on Apache HttpComponents, which handles regular requests and long polling requests (\"comet\"). By using NHttpRequestHandler you can delay the response for some reque

Say you have an application based on Apache HttpComponents, which handles regular requests and long polling requests ("comet"). By using NHttpRequestHandler you can delay the response for some requests and send the response immediately for other requests.

But how can you achieve a short socket timeout for the regular requests and a longer one for long polling requests? In some cases it may not be easy to tell the difference between the two types of request without beginning to process them. From testing it appears that setting a new timeout on the request object with setParams() will not affe开发者_如何学编程ct the timeout. Same for the response object.


One can set socket timeout value on the underlying HTTP connection by using HttpConnection#setSocketTimeout method.

0

精彩评论

暂无评论...
验证码 换一张
取 消