本文整理了Java中org.apache.commons.httpclient.HttpClient.getHttpConnectionManager()
方法的一些代码示例,展示了HttpClient.getHttpConnectionManager()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。HttpClient.getHttpConnectionManager()
方法的具体详情如下:
包路径:org.apache.commons.httpclient.HttpClient
类名称:HttpClient
方法名:getHttpConnectionManager
[英]Returns the HttpConnectionManager associated with the HttpClient.
[中]返回与HttpClient关联的HttpConnectionManager。
代码示例来源:origin: elastic/elasticsearch-hadoop
@Override
public void close() {
if (log.isTraceEnabled()) {
log.trace("Closing HTTP transport to " + httpInfo);
}
HttpConnectionManager manager = client.getHttpConnectionManager();
if (manager instanceof SocketTrackingConnectionManager) {
try {
((SocketTrackingConnectionManager) manager).close();
} catch (NullPointerException npe) {
// ignore
} catch (Exception ex) {
// log - not much else to do
log.warn("Exception closing underlying HTTP manager", ex);
}
}
}
代码示例来源:origin: apache/incubator-gobblin
@Override
public HttpClient create() throws Exception {
HttpClient client = new HttpClient();
if (soTimeout >= 0) {
client.getParams().setSoTimeout(soTimeout);
}
if (connTimeout >= 0) {
client.getHttpConnectionManager().getParams().setConnectionTimeout(connTimeout);
}
return client;
}
代码示例来源:origin: Alluxio/alluxio
/**
* Uses the post method to send a url with arguments by http, this method can call RESTful Api.
*
* @param url the http url
* @param timeout milliseconds to wait for the server to respond before giving up
* @param processInputStream the response body stream processor
*/
public static void post(String url, Integer timeout,
IProcessInputStream processInputStream)
throws IOException {
Preconditions.checkNotNull(timeout, "timeout");
Preconditions.checkNotNull(processInputStream, "processInputStream");
PostMethod postMethod = new PostMethod(url);
try {
HttpClient httpClient = new HttpClient();
httpClient.getHttpConnectionManager().getParams().setConnectionTimeout(timeout);
httpClient.getHttpConnectionManager().getParams().setSoTimeout(timeout);
int statusCode = httpClient.executeMethod(postMethod);
if (statusCode == HttpStatus.SC_OK || statusCode == HttpStatus.SC_CREATED) {
InputStream inputStream = postMethod.getResponseBodyAsStream();
processInputStream.process(inputStream);
} else {
throw new IOException("Failed to perform POST request. Status code: " + statusCode);
}
} finally {
postMethod.releaseConnection();
}
}
代码示例来源:origin: commons-httpclient/commons-httpclient
getHttpConnectionManager(),
hostconfig,
this.params,
代码示例来源:origin: elastic/elasticsearch-hadoop
completeAuth(authSettings);
HttpConnectionManagerParams connectionParams = client.getHttpConnectionManager().getParams();
代码示例来源:origin: foxinmy/weixin4j
private void resolveHttpParams(HttpParams params) {
if (params != null) {
if (params.getProxy() != null) {
InetSocketAddress socketAddress = (InetSocketAddress) params
.getProxy().address();
httpClient.getHostConfiguration().setProxy(
socketAddress.getHostName(), socketAddress.getPort());
}
if (params.getSSLContext() != null) {
Protocol.registerProtocol("https", new Protocol("https",
new SSLProtocolSocketFactory(params.getSSLContext()),
443));
}
httpClient.getHttpConnectionManager().getParams()
.setConnectionTimeout(params.getConnectTimeout());
}
}
代码示例来源:origin: org.alfresco/alfresco-core
@Override
public void close()
{
if(httpClient != null)
{
HttpConnectionManager connectionManager = httpClient.getHttpConnectionManager();
if(connectionManager instanceof MultiThreadedHttpConnectionManager)
{
((MultiThreadedHttpConnectionManager)connectionManager).shutdown();
}
}
}
代码示例来源:origin: org.apache.abdera/abdera-client
/**
* Return the HttpConnectionManagerParams object of the underlying HttpClient. This enables you to configure options
* not explicitly exposed by the AbderaClient
*/
public HttpConnectionManagerParams getHttpConnectionManagerParams() {
return client.getHttpConnectionManager().getParams();
}
代码示例来源:origin: otros-systems/otroslogviewer
public JumpToCodeClient(Configuration configuration) {
this.configuration = configuration;
this.client = new HttpClient();
//
client.getHttpConnectionManager().getParams().setConnectionTimeout(150);
locationInfoCache = CacheBuilder.newBuilder().maximumSize(5000).expireAfterAccess(15, TimeUnit.MINUTES).build();
locationSourceCache = CacheBuilder.newBuilder().maximumSize(1000).expireAfterAccess(15, TimeUnit.MINUTES).build();
ideCache = CacheBuilder.newBuilder().maximumSize(1).expireAfterWrite(10, TimeUnit.SECONDS).build();
}
代码示例来源:origin: org.springframework.android/spring-android-rest-template
/**
* Shutdown hook that closes the underlying {@link HttpConnectionManager}'s connection pool, if any.
*/
public void destroy() {
HttpConnectionManager connectionManager = getHttpClient().getHttpConnectionManager();
if (connectionManager instanceof MultiThreadedHttpConnectionManager) {
((MultiThreadedHttpConnectionManager) connectionManager).shutdown();
}
}
代码示例来源:origin: org.nuiton/maven-helper-plugin
protected HttpConnection getConnection() {
return client.getHttpConnectionManager().getConnection(
client.getHostConfiguration()
);
}
代码示例来源:origin: org.apache.abdera/abdera-client
/**
* Return the maximum number of connections allowed for the client
*/
public AbderaClient setMaxConnectionsTotal(int max) {
client.getHttpConnectionManager().getParams()
.setIntParameter(HttpConnectionManagerParams.MAX_TOTAL_CONNECTIONS, max);
return this;
}
代码示例来源:origin: org.springframework.ws/spring-ws-core
@Override
public void destroy() throws Exception {
HttpConnectionManager connectionManager = getHttpClient().getHttpConnectionManager();
if (connectionManager instanceof MultiThreadedHttpConnectionManager) {
((MultiThreadedHttpConnectionManager) connectionManager).shutdown();
}
}
代码示例来源:origin: org.springframework.ws/org.springframework.ws
/**
* Sets the maximum number of connections allowed for the underlying HttpClient.
*
* @param maxTotalConnections the maximum number of connections allowed
* @see org.apache.commons.httpclient.params.HttpConnectionManagerParams#setMaxTotalConnections(int)
*/
public void setMaxTotalConnections(int maxTotalConnections) {
if (maxTotalConnections <= 0) {
throw new IllegalArgumentException("maxTotalConnections must be a positive value");
}
getHttpClient().getHttpConnectionManager().getParams().setMaxTotalConnections(maxTotalConnections);
}
代码示例来源:origin: org.springframework.ws/spring-ws-core
/**
* Sets the timeout until a connection is etablished. A value of 0 means <em>never</em> timeout.
*
* @param timeout the timeout value in milliseconds
* @see org.apache.commons.httpclient.params.HttpConnectionManagerParams#setConnectionTimeout(int)
*/
public void setConnectionTimeout(int timeout) {
if (timeout < 0) {
throw new IllegalArgumentException("timeout must be a non-negative value");
}
getHttpClient().getHttpConnectionManager().getParams().setConnectionTimeout(timeout);
}
代码示例来源:origin: org.springframework.ws/spring-ws-core
/**
* Set the socket read timeout for the underlying HttpClient. A value of 0 means <em>never</em> timeout.
*
* @param timeout the timeout value in milliseconds
* @see org.apache.commons.httpclient.params.HttpConnectionManagerParams#setSoTimeout(int)
*/
public void setReadTimeout(int timeout) {
if (timeout < 0) {
throw new IllegalArgumentException("timeout must be a non-negative value");
}
getHttpClient().getHttpConnectionManager().getParams().setSoTimeout(timeout);
}
代码示例来源:origin: org.springframework.ws/spring-ws-core
/**
* Sets the maximum number of connections allowed for the underlying HttpClient.
*
* @param maxTotalConnections the maximum number of connections allowed
* @see org.apache.commons.httpclient.params.HttpConnectionManagerParams#setMaxTotalConnections(int)
*/
public void setMaxTotalConnections(int maxTotalConnections) {
if (maxTotalConnections <= 0) {
throw new IllegalArgumentException("maxTotalConnections must be a positive value");
}
getHttpClient().getHttpConnectionManager().getParams().setMaxTotalConnections(maxTotalConnections);
}
代码示例来源:origin: org.apache.commons/commons-vfs2
/** @since 2.0 */
@Override
public void closeCommunicationLink() {
if (getClient() != null) {
final HttpConnectionManager mgr = getClient().getHttpConnectionManager();
if (mgr instanceof MultiThreadedHttpConnectionManager) {
((MultiThreadedHttpConnectionManager) mgr).shutdown();
}
}
}
代码示例来源:origin: rometools/rome
ClientCollection(final String href, final AuthStrategy authStrategy) throws ProponoException {
super("Standalone connection", "text", href);
this.authStrategy = authStrategy;
try {
httpClient = new HttpClient(new MultiThreadedHttpConnectionManager());
// TODO: make connection timeout configurable
httpClient.getHttpConnectionManager().getParams().setConnectionTimeout(30000);
} catch (final Throwable t) {
throw new ProponoException("ERROR creating HTTPClient", t);
}
}
代码示例来源:origin: org.apache.xmlrpc/xmlrpc-client
protected void initHttpHeaders(XmlRpcRequest pRequest) throws XmlRpcClientException {
config = (XmlRpcHttpClientConfig) pRequest.getConfig();
method = newPostMethod(config);
super.initHttpHeaders(pRequest);
if (config.getConnectionTimeout() != 0)
client.getHttpConnectionManager().getParams().setConnectionTimeout(config.getConnectionTimeout());
if (config.getReplyTimeout() != 0)
client.getHttpConnectionManager().getParams().setSoTimeout(config.getReplyTimeout());
method.getParams().setVersion(HttpVersion.HTTP_1_1);
}
内容来源于网络,如有侵权,请联系作者删除!