本文整理了Java中org.apache.commons.httpclient.HttpConnection.close()
方法的一些代码示例,展示了HttpConnection.close()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。HttpConnection.close()
方法的具体详情如下:
包路径:org.apache.commons.httpclient.HttpConnection
类名称:HttpConnection
方法名:close
[英]Closes the socket and streams.
[中]关闭套接字和流。
代码示例来源:origin: commons-httpclient/commons-httpclient
/**
* since 3.1
*/
public void shutdown() {
httpConnection.close();
}
代码示例来源:origin: commons-httpclient/commons-httpclient
} catch (IOException e) {
LOG.debug("Closing the connection.");
this.conn.close();
if (this.conn.isOpen()) {
LOG.debug("Closing the connection.");
this.conn.close();
if (this.conn.isOpen()) {
LOG.debug("Closing the connection.");
this.conn.close();
代码示例来源:origin: commons-httpclient/commons-httpclient
/**
* Aborts the execution of this method.
*
* @since 3.0
*/
public void abort() {
if (this.aborted) {
return;
}
this.aborted = true;
HttpConnection conn = this.responseConnection;
if (conn != null) {
conn.close();
}
}
代码示例来源:origin: commons-httpclient/commons-httpclient
/**
* @since 3.0
*/
public void closeIdleConnections(long idleTimeout) {
long maxIdleTime = System.currentTimeMillis() - idleTimeout;
if (idleStartTime <= maxIdleTime) {
httpConnection.close();
}
}
代码示例来源:origin: commons-httpclient/commons-httpclient
public void close() {
if (hasConnection()) {
wrappedConnection.close();
} else {
// do nothing
}
}
代码示例来源:origin: commons-httpclient/commons-httpclient
/**
* @see HttpConnectionManager#releaseConnection(org.apache.commons.httpclient.HttpConnection)
*/
public void releaseConnection(HttpConnection conn) {
if (conn != httpConnection) {
throw new IllegalStateException("Unexpected release of an unknown connection.");
}
if (this.alwaysClose) {
httpConnection.close();
} else {
// make sure the connection is reuseable
finishLastResponse(httpConnection);
}
inUse = false;
// track the time the connection was made idle
idleStartTime = System.currentTimeMillis();
}
代码示例来源:origin: commons-httpclient/commons-httpclient
/**
* Closes the connection if stale.
*
* @return <code>true</code> if the connection was stale and therefore closed,
* <code>false</code> otherwise.
*
* @see #isStale()
*
* @since 3.0
*/
public boolean closeIfStale() throws IOException {
if (isOpen && isStale()) {
LOG.debug("Connection is stale, closing...");
close();
return true;
}
return false;
}
代码示例来源:origin: commons-httpclient/commons-httpclient
/**
* Closes connections that have been idle for at least the given amount of time.
*
* @param idleTime the minimum idle time, in milliseconds, for connections to be closed
*/
public void closeIdleConnections(long idleTime) {
// the latest time for which connections will be closed
long idleTimeout = System.currentTimeMillis() - idleTime;
if (LOG.isDebugEnabled()) {
LOG.debug("Checking for connections, idleTimeout: " + idleTimeout);
}
Iterator connectionIter = connectionToAdded.keySet().iterator();
while (connectionIter.hasNext()) {
HttpConnection conn = (HttpConnection) connectionIter.next();
Long connectionTime = (Long) connectionToAdded.get(conn);
if (connectionTime.longValue() <= idleTimeout) {
if (LOG.isDebugEnabled()) {
LOG.debug("Closing connection, connection time: " + connectionTime);
}
connectionIter.remove();
conn.close();
}
}
}
}
代码示例来源:origin: commons-httpclient/commons-httpclient
HttpConnection conn = (HttpConnection) iter.next();
iter.remove();
conn.close();
代码示例来源:origin: commons-httpclient/commons-httpclient
/**
* Since the same connection is about to be reused, make sure the
* previous request was completely processed, and if not
* consume it now.
* @param conn The connection
*/
static void finishLastResponse(HttpConnection conn) {
InputStream lastResponse = conn.getLastResponseInputStream();
if (lastResponse != null) {
conn.setLastResponseInputStream(null);
try {
lastResponse.close();
} catch (IOException ioe) {
conn.close();
}
}
}
代码示例来源:origin: elastic/elasticsearch-hadoop
public void close() {
if (httpConnection != null) {
if (httpConnection.isOpen()) {
releaseConnection(httpConnection);
}
httpConnection.close();
}
httpConnection = null;
conn = null;
}
}
代码示例来源:origin: commons-httpclient/commons-httpclient
connection.close();
代码示例来源:origin: commons-httpclient/commons-httpclient
/**
* Deletes the given connection. This will remove all reference to the connection
* so that it can be GCed.
*
* <p><b>Note:</b> Does not remove the connection from the freeConnections list. It
* is assumed that the caller has already handled this case.</p>
*
* @param connection The connection to delete
*/
private synchronized void deleteConnection(HttpConnection connection) {
HostConfiguration connectionConfiguration = configurationForConnection(connection);
if (LOG.isDebugEnabled()) {
LOG.debug("Reclaiming connection, hostConfig=" + connectionConfiguration);
}
connection.close();
HostConnectionPool hostPool = getHostPool(connectionConfiguration, true);
hostPool.freeConnections.remove(connection);
hostPool.numConnections--;
numConnections--;
if ((hostPool.numConnections == 0) &&
hostPool.waitingThreads.isEmpty()) {
mapHosts.remove(connectionConfiguration);
}
// remove the connection from the timeout handler
idleConnectionHandler.remove(connection);
}
代码示例来源:origin: commons-httpclient/commons-httpclient
conn.close();
return;
代码示例来源:origin: commons-httpclient/commons-httpclient
responseConnection.close();
} else {
try {
LOG.warn("Extra response data detected - closing connection");
responseConnection.close();
responseConnection.close();
代码示例来源:origin: commons-httpclient/commons-httpclient
response.setSocket(connectionManager.getConnection().getSocket());
} else {
connectionManager.getConnection().close();
代码示例来源:origin: commons-httpclient/commons-httpclient
return true;
} else {
this.conn.close();
return false;
代码示例来源:origin: commons-httpclient/commons-httpclient
httpConnection.close();
代码示例来源:origin: org.apache.commons/com.springsource.org.apache.commons.httpclient
public void close() {
if (hasConnection()) {
wrappedConnection.close();
} else {
// do nothing
}
}
代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.commons-httpclient
public void close() {
if (hasConnection()) {
wrappedConnection.close();
} else {
// do nothing
}
}
内容来源于网络,如有侵权,请联系作者删除!