开发者

Handling multiple requests over a single connection using httpcomponents?

开发者 https://www.devze.com 2023-04-07 20:07 出处:网络
I want to use a single connection to communicate with a client device. I am having problems keeping the connection alive. I\'m using DefaultConnectionReuseStrategy() which returns false for keepAlive

I want to use a single connection to communicate with a client device.

I am having problems keeping the connection alive. I'm using DefaultConnectionReuseStrategy() which returns false for keepAlive() after each request so the connection is always closed. I have set the Connection header to Keep-Alive but it still always closes the connection.

M开发者_开发百科y second problem is if I override keepAlive() to always return true, my client blocks while reading the input stream. How am I supposed to handle this? Should I be reading the content length header to find out how much to read? What if no content length is given?

0

精彩评论

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

关注公众号