use of org.graylog.shaded.elasticsearch7.org.apache.http.HttpHost in project robovm by robovm.
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.graylog.shaded.elasticsearch7.org.apache.http.HttpHost in project robovm by robovm.
the class AbstractPoolEntry method layerProtocol.
// tunnelProxy
/**
* Layers a protocol on top of an established tunnel.
*
* @param context the context for layering
* @param params the parameters for layering
*
* @throws IOException in case of a problem
*/
public void layerProtocol(HttpContext context, HttpParams params) throws IOException {
//@@@ 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 not open.");
}
if (!this.tracker.isTunnelled()) {
//@@@ allow this?
throw new IllegalStateException("Protocol layering without a tunnel not supported.");
}
if (this.tracker.isLayered()) {
throw new IllegalStateException("Multiple protocol layering not supported.");
}
// - collect the arguments
// - call the operator
// - update the tracking data
// In this order, we can be sure that only a successful
// layering on top of the connection will be tracked.
final HttpHost target = tracker.getTargetHost();
connOperator.updateSecureConnection(this.connection, target, context, params);
this.tracker.layerProtocol(this.connection.isSecure());
}
use of org.graylog.shaded.elasticsearch7.org.apache.http.HttpHost in project robovm by robovm.
the class DefaultHttpRoutePlanner method determineRoute.
// non-javadoc, see interface HttpRoutePlanner
public HttpRoute determineRoute(HttpHost target, HttpRequest request, HttpContext context) throws HttpException {
if (request == null) {
throw new IllegalStateException("Request must not be null.");
}
// If we have a forced route, we can do without a target.
HttpRoute route = ConnRouteParams.getForcedRoute(request.getParams());
if (route != null)
return route;
if (target == null) {
throw new IllegalStateException("Target host must not be null.");
}
final InetAddress local = ConnRouteParams.getLocalAddress(request.getParams());
final HttpHost proxy = ConnRouteParams.getDefaultProxy(request.getParams());
final Scheme schm = schemeRegistry.getScheme(target.getSchemeName());
// as it is typically used for TLS/SSL, we assume that
// a layered scheme implies a secure connection
final boolean secure = schm.isLayered();
if (proxy == null) {
route = new HttpRoute(target, local, secure);
} else {
route = new HttpRoute(target, local, proxy, secure);
}
return route;
}
use of org.graylog.shaded.elasticsearch7.org.apache.http.HttpHost in project robovm by robovm.
the class ProxySelectorRoutePlanner method determineRoute.
// non-javadoc, see interface HttpRoutePlanner
public HttpRoute determineRoute(HttpHost target, HttpRequest request, HttpContext context) throws HttpException {
if (request == null) {
throw new IllegalStateException("Request must not be null.");
}
// If we have a forced route, we can do without a target.
HttpRoute route = ConnRouteParams.getForcedRoute(request.getParams());
if (route != null)
return route;
if (target == null) {
throw new IllegalStateException("Target host must not be null.");
}
final InetAddress local = ConnRouteParams.getLocalAddress(request.getParams());
// BEGIN android-changed
// If the client or request explicitly specifies a proxy (or no
// proxy), prefer that over the ProxySelector's VM-wide default.
HttpHost proxy = (HttpHost) request.getParams().getParameter(ConnRoutePNames.DEFAULT_PROXY);
if (proxy == null) {
proxy = determineProxy(target, request, context);
} else if (ConnRouteParams.NO_HOST.equals(proxy)) {
// value is explicitly unset
proxy = null;
}
// END android-changed
final Scheme schm = this.schemeRegistry.getScheme(target.getSchemeName());
// as it is typically used for TLS/SSL, we assume that
// a layered scheme implies a secure connection
final boolean secure = schm.isLayered();
if (proxy == null) {
route = new HttpRoute(target, local, secure);
} else {
route = new HttpRoute(target, local, proxy, secure);
}
return route;
}
use of org.graylog.shaded.elasticsearch7.org.apache.http.HttpHost in project XobotOS by xamarin.
the class HttpRoute method toChain.
/**
* Helper to duplicate and check a proxy chain.
* An empty proxy chain is converted to <code>null</code>.
*
* @param proxies the proxy chain to duplicate, or <code>null</code>
*
* @return a new proxy chain array, or <code>null</code>
*/
private static HttpHost[] toChain(HttpHost[] proxies) {
if ((proxies == null) || (proxies.length < 1))
return null;
for (HttpHost proxy : proxies) {
if (proxy == null)
throw new IllegalArgumentException("Proxy chain may not contain null elements.");
}
// copy the proxy chain, the traditional way
HttpHost[] result = new HttpHost[proxies.length];
System.arraycopy(proxies, 0, result, 0, proxies.length);
return result;
}
Aggregations