在Apache HttpClient中禁用“保持活动" [英] Disable Keep Alive in Apache HttpClient

查看:74
本文介绍了在Apache HttpClient中禁用“保持活动"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

对于某些我们无法解决的问题,我想在Apache HttpClient 3.1上禁用保持活动状态.但是,我在Internet上找不到任何资源.你知道怎么做吗?

For some problem that we couldn't solve, I want to disable keep alive on Apache HttpClient 3.1. However, I couldn't find any resource on the Internet for that. Do you know how to do it?

推荐答案

您可以在方法上禁用HTTP 1.1支持,即httpMethod.setHttp11(false);,但是您将失去其他一些功能.

You can disable HTTP 1.1 support on you method, i.e. httpMethod.setHttp11(false); but you will lost some other features.

您还可以尝试强制连接标头在响应后请求服务器关闭连接:httpMethod.setRequestHeader("Connection", "close").

You can also try to force the connection header to ask the server to close the connection after its response: httpMethod.setRequestHeader("Connection", "close").

这篇关于在Apache HttpClient中禁用“保持活动"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆