private InetSocketAddress remoteAddress(Request request, Uri uri, ProxyServer proxy, boolean useProxy) throws UnknownHostException { InetAddress address; int port = getDefaultPort(uri); if (request.getInetAddress() != null) { address = request.getInetAddress(); } else if (!useProxy || avoidProxy(proxy, uri.getHost())) { address = request.getNameResolver().resolve(uri.getHost()); } else { address = request.getNameResolver().resolve(proxy.getHost()); port = proxy.getPort(); } return new InetSocketAddress(address, port); }
private InetSocketAddress remoteAddress(Request request, Uri uri, ProxyServer proxy, boolean useProxy) throws UnknownHostException { InetAddress address; int port = getDefaultPort(uri); if (request.getInetAddress() != null) { address = request.getInetAddress(); } else if (!useProxy || avoidProxy(proxy, uri.getHost())) { address = request.getNameResolver().resolve(uri.getHost()); } else { address = request.getNameResolver().resolve(proxy.getHost()); port = proxy.getPort(); } return new InetSocketAddress(address, port); }
public ChannelConnector(Request request, ProxyServer proxy, boolean useProxy, AsyncHandler<?> asyncHandler) throws UnknownHostException { this.asyncHandlerExtensions = asyncHandler instanceof AsyncHandlerExtensions ? (AsyncHandlerExtensions) asyncHandler : null; NameResolution[] resolutions; Uri uri = request.getUri(); int port = uri.getExplicitPort(); if (request.getInetAddress() != null) { resolutions = new NameResolution[] { new NameResolution(request.getInetAddress()) }; } else if (!useProxy || ignoreProxy(proxy, uri.getHost())) { resolutions = request.getNameResolver().resolve(uri.getHost()); } else { resolutions = request.getNameResolver().resolve(proxy.getHost()); port = uri.isSecured() ? proxy.getSecuredPort(): proxy.getPort(); } if (asyncHandlerExtensions != null) asyncHandlerExtensions.onDnsResolved(resolutions); remoteAddresses = new InetSocketAddress[resolutions.length]; for (int i = 0; i < resolutions.length; i ++) { remoteAddresses[i] = new InetSocketAddress(resolutions[i].address, port); } if (request.getLocalAddress() != null) { localAddress = new InetSocketAddress(request.getLocalAddress(), 0); } else { localAddress = null; } }
public RequestImpl(Request prototype) { if (prototype != null) { this.method = prototype.getMethod(); this.uri = prototype.getUri(); this.address = prototype.getInetAddress(); this.localAddress = prototype.getLocalAddress(); this.headers = new FluentCaseInsensitiveStringsMap(prototype.getHeaders()); this.cookies = new ArrayList<>(prototype.getCookies()); this.byteData = prototype.getByteData(); this.compositeByteData = prototype.getCompositeByteData(); this.stringData = prototype.getStringData(); this.byteBufferData = prototype.getByteBufferData(); this.streamData = prototype.getStreamData(); this.bodyGenerator = prototype.getBodyGenerator(); this.formParams = prototype.getFormParams() == null ? null : new ArrayList<>(prototype.getFormParams()); this.parts = prototype.getParts() == null ? null : new ArrayList<>(prototype.getParts()); this.virtualHost = prototype.getVirtualHost(); this.length = prototype.getContentLength(); this.proxyServer = prototype.getProxyServer(); this.realm = prototype.getRealm(); this.file = prototype.getFile(); this.followRedirect = prototype.getFollowRedirect(); this.requestTimeout = prototype.getRequestTimeout(); this.rangeOffset = prototype.getRangeOffset(); this.charset = prototype.getBodyCharset(); this.connectionPoolPartitioning = prototype.getConnectionPoolPartitioning(); this.nameResolver = prototype.getNameResolver(); } }