use of org.apache.http.conn.routing.RouteTracker in project platform_external_apache-http by android.
the class AbstractPoolEntry method open.
/**
* Opens the underlying connection.
*
* @param route the route along which to open the connection
* @param context the context for opening the connection
* @param params the parameters for opening the connection
*
* @throws IOException in case of a problem
*/
public void open(HttpRoute route, HttpContext context, HttpParams params) throws IOException {
if (route == null) {
throw new IllegalArgumentException("Route must not be null.");
}
//@@@ is context allowed to be null? depends on operator?
if (params == null) {
throw new IllegalArgumentException("Parameters must not be null.");
}
if ((this.tracker != null) && this.tracker.isConnected()) {
throw new IllegalStateException("Connection already open.");
}
// - collect the arguments
// - call the operator
// - update the tracking data
// In this order, we can be sure that only a successful
// opening of the connection will be tracked.
//@@@ verify route against planned route?
this.tracker = new RouteTracker(route);
final HttpHost proxy = route.getProxyHost();
connOperator.openConnection(this.connection, (proxy != null) ? proxy : route.getTargetHost(), route.getLocalAddress(), context, params);
// capture volatile
RouteTracker localTracker = tracker;
// fail early.
if (localTracker == null) {
throw new IOException("Request aborted");
}
if (proxy == null) {
localTracker.connectTarget(this.connection.isSecure());
} else {
localTracker.connectProxy(proxy, this.connection.isSecure());
}
}
use of org.apache.http.conn.routing.RouteTracker in project jmeter by apache.
the class ManagedClientConnectionImpl method open.
@Override
public void open(final HttpRoute route, final HttpContext context, final HttpParams params) throws IOException {
Args.notNull(route, "Route");
Args.notNull(params, "HTTP parameters");
final OperatedClientConnection conn;
synchronized (this) {
if (this.poolEntry == null) {
throw new ConnectionShutdownException();
}
final RouteTracker tracker = this.poolEntry.getTracker();
Asserts.notNull(tracker, "Route tracker");
Asserts.check(!tracker.isConnected(), "Connection already open");
conn = this.poolEntry.getConnection();
}
final HttpHost proxy = route.getProxyHost();
this.operator.openConnection(conn, (proxy != null) ? proxy : route.getTargetHost(), route.getLocalAddress(), context, params);
synchronized (this) {
if (this.poolEntry == null) {
throw new InterruptedIOException();
}
final RouteTracker tracker = this.poolEntry.getTracker();
if (proxy == null) {
tracker.connectTarget(conn.isSecure());
} else {
tracker.connectProxy(proxy, conn.isSecure());
}
}
}
use of org.apache.http.conn.routing.RouteTracker in project jmeter by apache.
the class ManagedClientConnectionImpl method tunnelTarget.
@Override
public void tunnelTarget(final boolean secure, final HttpParams params) throws IOException {
Args.notNull(params, "HTTP parameters");
final HttpHost target;
final OperatedClientConnection conn;
synchronized (this) {
if (this.poolEntry == null) {
throw new ConnectionShutdownException();
}
final RouteTracker tracker = this.poolEntry.getTracker();
Asserts.notNull(tracker, "Route tracker");
Asserts.check(tracker.isConnected(), "Connection not open");
Asserts.check(!tracker.isTunnelled(), "Connection is already tunnelled");
target = tracker.getTargetHost();
conn = this.poolEntry.getConnection();
}
conn.update(null, target, secure, params);
synchronized (this) {
if (this.poolEntry == null) {
throw new InterruptedIOException();
}
final RouteTracker tracker = this.poolEntry.getTracker();
tracker.tunnelTarget(secure);
}
}
use of org.apache.http.conn.routing.RouteTracker in project jmeter by apache.
the class ManagedClientConnectionImpl method tunnelProxy.
@Override
public void tunnelProxy(final HttpHost next, final boolean secure, final HttpParams params) throws IOException {
Args.notNull(next, "Next proxy");
Args.notNull(params, "HTTP parameters");
final OperatedClientConnection conn;
synchronized (this) {
if (this.poolEntry == null) {
throw new ConnectionShutdownException();
}
final RouteTracker tracker = this.poolEntry.getTracker();
Asserts.notNull(tracker, "Route tracker");
Asserts.check(tracker.isConnected(), "Connection not open");
conn = this.poolEntry.getConnection();
}
conn.update(null, next, secure, params);
synchronized (this) {
if (this.poolEntry == null) {
throw new InterruptedIOException();
}
final RouteTracker tracker = this.poolEntry.getTracker();
tracker.tunnelProxy(next, secure);
}
}
use of org.apache.http.conn.routing.RouteTracker in project jmeter by apache.
the class ManagedClientConnectionImpl method layerProtocol.
@Override
public void layerProtocol(final HttpContext context, final HttpParams params) throws IOException {
Args.notNull(params, "HTTP parameters");
final HttpHost target;
final OperatedClientConnection conn;
synchronized (this) {
if (this.poolEntry == null) {
throw new ConnectionShutdownException();
}
final RouteTracker tracker = this.poolEntry.getTracker();
Asserts.notNull(tracker, "Route tracker");
Asserts.check(tracker.isConnected(), "Connection not open");
Asserts.check(tracker.isTunnelled(), "Protocol layering without a tunnel not supported");
Asserts.check(!tracker.isLayered(), "Multiple protocol layering not supported");
target = tracker.getTargetHost();
conn = this.poolEntry.getConnection();
}
this.operator.updateSecureConnection(conn, target, context, params);
synchronized (this) {
if (this.poolEntry == null) {
throw new InterruptedIOException();
}
final RouteTracker tracker = this.poolEntry.getTracker();
tracker.layerProtocol(conn.isSecure());
}
}
Aggregations