|
|
@ -41,7 +41,6 @@ import com.fr.third.org.apache.http.HttpException; |
|
|
|
import com.fr.third.org.apache.http.HttpHost; |
|
|
|
import com.fr.third.org.apache.http.HttpHost; |
|
|
|
import com.fr.third.org.apache.http.HttpRequest; |
|
|
|
import com.fr.third.org.apache.http.HttpRequest; |
|
|
|
import com.fr.third.org.apache.http.HttpResponse; |
|
|
|
import com.fr.third.org.apache.http.HttpResponse; |
|
|
|
import com.fr.third.org.apache.http.annotation.NotThreadSafe; |
|
|
|
|
|
|
|
import com.fr.third.org.apache.http.conn.ClientConnectionManager; |
|
|
|
import com.fr.third.org.apache.http.conn.ClientConnectionManager; |
|
|
|
import com.fr.third.org.apache.http.conn.ClientConnectionOperator; |
|
|
|
import com.fr.third.org.apache.http.conn.ClientConnectionOperator; |
|
|
|
import com.fr.third.org.apache.http.conn.ManagedClientConnection; |
|
|
|
import com.fr.third.org.apache.http.conn.ManagedClientConnection; |
|
|
@ -59,7 +58,6 @@ import com.fr.third.org.apache.http.util.Asserts; |
|
|
|
* @deprecated (4.3) use {@link ManagedHttpClientConnectionFactory}. |
|
|
|
* @deprecated (4.3) use {@link ManagedHttpClientConnectionFactory}. |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
@Deprecated |
|
|
|
@Deprecated |
|
|
|
@NotThreadSafe |
|
|
|
|
|
|
|
class ManagedClientConnectionImpl implements ManagedClientConnection { |
|
|
|
class ManagedClientConnectionImpl implements ManagedClientConnection { |
|
|
|
|
|
|
|
|
|
|
|
private final ClientConnectionManager manager; |
|
|
|
private final ClientConnectionManager manager; |
|
|
@ -83,6 +81,7 @@ class ManagedClientConnectionImpl implements ManagedClientConnection { |
|
|
|
this.duration = Long.MAX_VALUE; |
|
|
|
this.duration = Long.MAX_VALUE; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
public String getId() { |
|
|
|
public String getId() { |
|
|
|
return null; |
|
|
|
return null; |
|
|
|
} |
|
|
|
} |
|
|
@ -125,6 +124,7 @@ class ManagedClientConnectionImpl implements ManagedClientConnection { |
|
|
|
return local; |
|
|
|
return local; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
public void close() throws IOException { |
|
|
|
public void close() throws IOException { |
|
|
|
final HttpPoolEntry local = this.poolEntry; |
|
|
|
final HttpPoolEntry local = this.poolEntry; |
|
|
|
if (local != null) { |
|
|
|
if (local != null) { |
|
|
@ -134,6 +134,7 @@ class ManagedClientConnectionImpl implements ManagedClientConnection { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
public void shutdown() throws IOException { |
|
|
|
public void shutdown() throws IOException { |
|
|
|
final HttpPoolEntry local = this.poolEntry; |
|
|
|
final HttpPoolEntry local = this.poolEntry; |
|
|
|
if (local != null) { |
|
|
|
if (local != null) { |
|
|
@ -143,6 +144,7 @@ class ManagedClientConnectionImpl implements ManagedClientConnection { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
public boolean isOpen() { |
|
|
|
public boolean isOpen() { |
|
|
|
final OperatedClientConnection conn = getConnection(); |
|
|
|
final OperatedClientConnection conn = getConnection(); |
|
|
|
if (conn != null) { |
|
|
|
if (conn != null) { |
|
|
@ -152,6 +154,7 @@ class ManagedClientConnectionImpl implements ManagedClientConnection { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
public boolean isStale() { |
|
|
|
public boolean isStale() { |
|
|
|
final OperatedClientConnection conn = getConnection(); |
|
|
|
final OperatedClientConnection conn = getConnection(); |
|
|
|
if (conn != null) { |
|
|
|
if (conn != null) { |
|
|
@ -161,88 +164,105 @@ class ManagedClientConnectionImpl implements ManagedClientConnection { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
public void setSocketTimeout(final int timeout) { |
|
|
|
public void setSocketTimeout(final int timeout) { |
|
|
|
final OperatedClientConnection conn = ensureConnection(); |
|
|
|
final OperatedClientConnection conn = ensureConnection(); |
|
|
|
conn.setSocketTimeout(timeout); |
|
|
|
conn.setSocketTimeout(timeout); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
public int getSocketTimeout() { |
|
|
|
public int getSocketTimeout() { |
|
|
|
final OperatedClientConnection conn = ensureConnection(); |
|
|
|
final OperatedClientConnection conn = ensureConnection(); |
|
|
|
return conn.getSocketTimeout(); |
|
|
|
return conn.getSocketTimeout(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
public HttpConnectionMetrics getMetrics() { |
|
|
|
public HttpConnectionMetrics getMetrics() { |
|
|
|
final OperatedClientConnection conn = ensureConnection(); |
|
|
|
final OperatedClientConnection conn = ensureConnection(); |
|
|
|
return conn.getMetrics(); |
|
|
|
return conn.getMetrics(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
public void flush() throws IOException { |
|
|
|
public void flush() throws IOException { |
|
|
|
final OperatedClientConnection conn = ensureConnection(); |
|
|
|
final OperatedClientConnection conn = ensureConnection(); |
|
|
|
conn.flush(); |
|
|
|
conn.flush(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
public boolean isResponseAvailable(final int timeout) throws IOException { |
|
|
|
public boolean isResponseAvailable(final int timeout) throws IOException { |
|
|
|
final OperatedClientConnection conn = ensureConnection(); |
|
|
|
final OperatedClientConnection conn = ensureConnection(); |
|
|
|
return conn.isResponseAvailable(timeout); |
|
|
|
return conn.isResponseAvailable(timeout); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
public void receiveResponseEntity( |
|
|
|
public void receiveResponseEntity( |
|
|
|
final HttpResponse response) throws HttpException, IOException { |
|
|
|
final HttpResponse response) throws HttpException, IOException { |
|
|
|
final OperatedClientConnection conn = ensureConnection(); |
|
|
|
final OperatedClientConnection conn = ensureConnection(); |
|
|
|
conn.receiveResponseEntity(response); |
|
|
|
conn.receiveResponseEntity(response); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
public HttpResponse receiveResponseHeader() throws HttpException, IOException { |
|
|
|
public HttpResponse receiveResponseHeader() throws HttpException, IOException { |
|
|
|
final OperatedClientConnection conn = ensureConnection(); |
|
|
|
final OperatedClientConnection conn = ensureConnection(); |
|
|
|
return conn.receiveResponseHeader(); |
|
|
|
return conn.receiveResponseHeader(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
public void sendRequestEntity( |
|
|
|
public void sendRequestEntity( |
|
|
|
final HttpEntityEnclosingRequest request) throws HttpException, IOException { |
|
|
|
final HttpEntityEnclosingRequest request) throws HttpException, IOException { |
|
|
|
final OperatedClientConnection conn = ensureConnection(); |
|
|
|
final OperatedClientConnection conn = ensureConnection(); |
|
|
|
conn.sendRequestEntity(request); |
|
|
|
conn.sendRequestEntity(request); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
public void sendRequestHeader( |
|
|
|
public void sendRequestHeader( |
|
|
|
final HttpRequest request) throws HttpException, IOException { |
|
|
|
final HttpRequest request) throws HttpException, IOException { |
|
|
|
final OperatedClientConnection conn = ensureConnection(); |
|
|
|
final OperatedClientConnection conn = ensureConnection(); |
|
|
|
conn.sendRequestHeader(request); |
|
|
|
conn.sendRequestHeader(request); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
public InetAddress getLocalAddress() { |
|
|
|
public InetAddress getLocalAddress() { |
|
|
|
final OperatedClientConnection conn = ensureConnection(); |
|
|
|
final OperatedClientConnection conn = ensureConnection(); |
|
|
|
return conn.getLocalAddress(); |
|
|
|
return conn.getLocalAddress(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
public int getLocalPort() { |
|
|
|
public int getLocalPort() { |
|
|
|
final OperatedClientConnection conn = ensureConnection(); |
|
|
|
final OperatedClientConnection conn = ensureConnection(); |
|
|
|
return conn.getLocalPort(); |
|
|
|
return conn.getLocalPort(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
public InetAddress getRemoteAddress() { |
|
|
|
public InetAddress getRemoteAddress() { |
|
|
|
final OperatedClientConnection conn = ensureConnection(); |
|
|
|
final OperatedClientConnection conn = ensureConnection(); |
|
|
|
return conn.getRemoteAddress(); |
|
|
|
return conn.getRemoteAddress(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
public int getRemotePort() { |
|
|
|
public int getRemotePort() { |
|
|
|
final OperatedClientConnection conn = ensureConnection(); |
|
|
|
final OperatedClientConnection conn = ensureConnection(); |
|
|
|
return conn.getRemotePort(); |
|
|
|
return conn.getRemotePort(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
public boolean isSecure() { |
|
|
|
public boolean isSecure() { |
|
|
|
final OperatedClientConnection conn = ensureConnection(); |
|
|
|
final OperatedClientConnection conn = ensureConnection(); |
|
|
|
return conn.isSecure(); |
|
|
|
return conn.isSecure(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
public void bind(final Socket socket) throws IOException { |
|
|
|
public void bind(final Socket socket) throws IOException { |
|
|
|
throw new UnsupportedOperationException(); |
|
|
|
throw new UnsupportedOperationException(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
public Socket getSocket() { |
|
|
|
public Socket getSocket() { |
|
|
|
final OperatedClientConnection conn = ensureConnection(); |
|
|
|
final OperatedClientConnection conn = ensureConnection(); |
|
|
|
return conn.getSocket(); |
|
|
|
return conn.getSocket(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
public SSLSession getSSLSession() { |
|
|
|
public SSLSession getSSLSession() { |
|
|
|
final OperatedClientConnection conn = ensureConnection(); |
|
|
|
final OperatedClientConnection conn = ensureConnection(); |
|
|
|
SSLSession result = null; |
|
|
|
SSLSession result = null; |
|
|
@ -278,11 +298,13 @@ class ManagedClientConnectionImpl implements ManagedClientConnection { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
public HttpRoute getRoute() { |
|
|
|
public HttpRoute getRoute() { |
|
|
|
final HttpPoolEntry local = ensurePoolEntry(); |
|
|
|
final HttpPoolEntry local = ensurePoolEntry(); |
|
|
|
return local.getEffectiveRoute(); |
|
|
|
return local.getEffectiveRoute(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
public void open( |
|
|
|
public void open( |
|
|
|
final HttpRoute route, |
|
|
|
final HttpRoute route, |
|
|
|
final HttpContext context, |
|
|
|
final HttpContext context, |
|
|
@ -320,6 +342,7 @@ class ManagedClientConnectionImpl implements ManagedClientConnection { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
public void tunnelTarget( |
|
|
|
public void tunnelTarget( |
|
|
|
final boolean secure, final HttpParams params) throws IOException { |
|
|
|
final boolean secure, final HttpParams params) throws IOException { |
|
|
|
Args.notNull(params, "HTTP parameters"); |
|
|
|
Args.notNull(params, "HTTP parameters"); |
|
|
@ -348,6 +371,7 @@ class ManagedClientConnectionImpl implements ManagedClientConnection { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
public void tunnelProxy( |
|
|
|
public void tunnelProxy( |
|
|
|
final HttpHost next, final boolean secure, final HttpParams params) throws IOException { |
|
|
|
final HttpHost next, final boolean secure, final HttpParams params) throws IOException { |
|
|
|
Args.notNull(next, "Next proxy"); |
|
|
|
Args.notNull(next, "Next proxy"); |
|
|
@ -374,6 +398,7 @@ class ManagedClientConnectionImpl implements ManagedClientConnection { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
public void layerProtocol( |
|
|
|
public void layerProtocol( |
|
|
|
final HttpContext context, final HttpParams params) throws IOException { |
|
|
|
final HttpContext context, final HttpParams params) throws IOException { |
|
|
|
Args.notNull(params, "HTTP parameters"); |
|
|
|
Args.notNull(params, "HTTP parameters"); |
|
|
@ -402,28 +427,34 @@ class ManagedClientConnectionImpl implements ManagedClientConnection { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
public Object getState() { |
|
|
|
public Object getState() { |
|
|
|
final HttpPoolEntry local = ensurePoolEntry(); |
|
|
|
final HttpPoolEntry local = ensurePoolEntry(); |
|
|
|
return local.getState(); |
|
|
|
return local.getState(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
public void setState(final Object state) { |
|
|
|
public void setState(final Object state) { |
|
|
|
final HttpPoolEntry local = ensurePoolEntry(); |
|
|
|
final HttpPoolEntry local = ensurePoolEntry(); |
|
|
|
local.setState(state); |
|
|
|
local.setState(state); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
public void markReusable() { |
|
|
|
public void markReusable() { |
|
|
|
this.reusable = true; |
|
|
|
this.reusable = true; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
public void unmarkReusable() { |
|
|
|
public void unmarkReusable() { |
|
|
|
this.reusable = false; |
|
|
|
this.reusable = false; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
public boolean isMarkedReusable() { |
|
|
|
public boolean isMarkedReusable() { |
|
|
|
return this.reusable; |
|
|
|
return this.reusable; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
public void setIdleDuration(final long duration, final TimeUnit unit) { |
|
|
|
public void setIdleDuration(final long duration, final TimeUnit unit) { |
|
|
|
if(duration > 0) { |
|
|
|
if(duration > 0) { |
|
|
|
this.duration = unit.toMillis(duration); |
|
|
|
this.duration = unit.toMillis(duration); |
|
|
@ -432,6 +463,7 @@ class ManagedClientConnectionImpl implements ManagedClientConnection { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
public void releaseConnection() { |
|
|
|
public void releaseConnection() { |
|
|
|
synchronized (this) { |
|
|
|
synchronized (this) { |
|
|
|
if (this.poolEntry == null) { |
|
|
|
if (this.poolEntry == null) { |
|
|
@ -442,6 +474,7 @@ class ManagedClientConnectionImpl implements ManagedClientConnection { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
public void abortConnection() { |
|
|
|
public void abortConnection() { |
|
|
|
synchronized (this) { |
|
|
|
synchronized (this) { |
|
|
|
if (this.poolEntry == null) { |
|
|
|
if (this.poolEntry == null) { |
|
|
|