use of org.graylog.shaded.elasticsearch7.org.apache.http.HttpHost in project XobotOS by xamarin.
the class HttpRoute method hashCode.
/**
* Generates a hash code for this route.
*
* @return the hash code
*/
@Override
public final int hashCode() {
int hc = this.targetHost.hashCode();
if (this.localAddress != null)
hc ^= localAddress.hashCode();
if (this.proxyChain != null) {
hc ^= proxyChain.length;
for (HttpHost aProxyChain : proxyChain) hc ^= aProxyChain.hashCode();
}
if (this.secure)
hc ^= 0x11111111;
hc ^= this.tunnelled.hashCode();
hc ^= this.layered.hashCode();
return hc;
}
use of org.graylog.shaded.elasticsearch7.org.apache.http.HttpHost in project XobotOS by xamarin.
the class RouteTracker method getHopTarget.
// non-JavaDoc, see interface RouteInfo
public final HttpHost getHopTarget(int hop) {
if (hop < 0)
throw new IllegalArgumentException("Hop index must not be negative: " + hop);
final int hopcount = getHopCount();
if (hop >= hopcount) {
throw new IllegalArgumentException("Hop index " + hop + " exceeds tracked route length " + hopcount + ".");
}
HttpHost result = null;
if (hop < hopcount - 1)
result = this.proxyChain[hop];
else
result = this.targetHost;
return result;
}
use of org.graylog.shaded.elasticsearch7.org.apache.http.HttpHost in project XobotOS by xamarin.
the class HttpRoute method toString.
/**
* Obtains a description of this route.
*
* @return a human-readable representation of this route
*/
@Override
public final String toString() {
StringBuilder cab = new StringBuilder(50 + getHopCount() * 30);
cab.append("HttpRoute[");
if (this.localAddress != null) {
cab.append(this.localAddress);
cab.append("->");
}
cab.append('{');
if (this.tunnelled == TunnelType.TUNNELLED)
cab.append('t');
if (this.layered == LayerType.LAYERED)
cab.append('l');
if (this.secure)
cab.append('s');
cab.append("}->");
if (this.proxyChain != null) {
for (HttpHost aProxyChain : this.proxyChain) {
cab.append(aProxyChain);
cab.append("->");
}
}
cab.append(this.targetHost);
cab.append(']');
return cab.toString();
}
use of org.graylog.shaded.elasticsearch7.org.apache.http.HttpHost in project XobotOS by xamarin.
the class RequestQueue method queueRequest.
protected synchronized void queueRequest(Request request, boolean head) {
HttpHost host = request.mProxyHost == null ? request.mHost : request.mProxyHost;
LinkedList<Request> reqList;
if (mPending.containsKey(host)) {
reqList = mPending.get(host);
} else {
reqList = new LinkedList<Request>();
mPending.put(host, reqList);
}
if (head) {
reqList.addFirst(request);
} else {
reqList.add(request);
}
}
use of org.graylog.shaded.elasticsearch7.org.apache.http.HttpHost in project XobotOS by xamarin.
the class ProxySelectorRoutePlanner method determineProxy.
/**
* Determines a proxy for the given target.
*
* @param target the planned target, never <code>null</code>
* @param request the request to be sent, never <code>null</code>
* @param context the context, or <code>null</code>
*
* @return the proxy to use, or <code>null</code> for a direct route
*
* @throws HttpException
* in case of system proxy settings that cannot be handled
*/
protected HttpHost determineProxy(HttpHost target, HttpRequest request, HttpContext context) throws HttpException {
// the proxy selector can be 'unset', so we better deal with null here
ProxySelector psel = this.proxySelector;
if (psel == null)
psel = ProxySelector.getDefault();
if (psel == null)
return null;
URI targetURI = null;
try {
targetURI = new URI(target.toURI());
} catch (URISyntaxException usx) {
throw new HttpException("Cannot convert host to URI: " + target, usx);
}
List<Proxy> proxies = psel.select(targetURI);
Proxy p = chooseProxy(proxies, target, request, context);
HttpHost result = null;
if (p.type() == Proxy.Type.HTTP) {
// convert the socket address to an HttpHost
if (!(p.address() instanceof InetSocketAddress)) {
throw new HttpException("Unable to handle non-Inet proxy address: " + p.address());
}
final InetSocketAddress isa = (InetSocketAddress) p.address();
// assume default scheme (http)
result = new HttpHost(getHost(isa), isa.getPort());
}
return result;
}
Aggregations