Refine search
@Override public HttpParams setParameter(String name, Object value) { if (name.equals(ConnRouteParams.DEFAULT_PROXY)) { HttpHost host = (HttpHost) value; Proxy proxy = null; if (host != null) { proxy = new Proxy(HTTP, new InetSocketAddress(host.getHostName(), host.getPort())); } client = client.newBuilder() .proxy(proxy) .build(); return this; } throw new IllegalArgumentException(name); }
@Override protected HttpHost determineProxy(HttpHost target, HttpRequest request, HttpContext context) throws HttpException { HttpHost httpHost = super.determineProxy(target, request, context); if (scheme != null && !scheme.equalsIgnoreCase(httpHost.getSchemeName())) { httpHost = new HttpHost(httpHost.getHostName(), httpHost.getPort(), scheme); } return httpHost; } }
public boolean isApiHost(HttpHost host) { return ("http".equals(host.getSchemeName()) || "https".equals(host.getSchemeName())) && resourceHost.getHostName().equals(host.getHostName()); }
/** * Set credentials to field <code>credsProvider</code>. * * @param username the username, part of credentials * @param password the password, part of credentials */ public void setCredentials(String username, String password) { credsProvider.setCredentials( new AuthScope(host.getHostName(), host.getPort(), AuthScope.ANY_REALM), new UsernamePasswordCredentials(username, password)); }
String host = target.getHostName(); int port = target.getPort(); if (port < 0) { Scheme scheme = connManager.getSchemeRegistry(). getScheme(target.getSchemeName()); port = scheme.getDefaultPort();
private static URI hostToUri(HttpHost host) { try { return new URI(host.getSchemeName(), host.getHostName(), null, null); } catch (URISyntaxException ignored) { throw new RuntimeException(); } } }
@Override public void process(HttpRequest request, HttpContext context) { AuthState authState = (AuthState) context.getAttribute(HttpClientContext.TARGET_AUTH_STATE); if (authState.getAuthScheme() == null) { CredentialsProvider credsProvider = (CredentialsProvider) context.getAttribute(HttpClientContext.CREDS_PROVIDER); HttpHost targetHost = (HttpHost) context.getAttribute(HttpCoreContext.HTTP_TARGET_HOST); Credentials credentials = credsProvider.getCredentials( new AuthScope(targetHost.getHostName(), targetHost.getPort())); if (credentials != null) { authState.update(new BasicScheme(), credentials); } } } }
target.getSchemeName(), target.getHostName(), target.getPort(), uri.getRawPath(), uri.getRawQuery(),
@Override protected HttpHost determineProxy(final HttpHost host, final HttpRequest request, final HttpContext context) throws HttpException { if (noProxyFor(host.getHostName())) { return null; } return proxies.get(host.getSchemeName()); }
CredentialsProvider credsProvider = new BasicCredentialsProvider(); credsProvider.setCredentials( new AuthScope( target.getHostName(), target.getPort() ), new UsernamePasswordCredentials( user, password ) );
@Override public HttpRoute determineRoute(HttpHost host, HttpRequest request, HttpContext context) throws HttpException { Args.notNull(host, "Target host"); Args.notNull(request, "Request"); final HttpClientContext clientContext = HttpClientContext.adapt(context); final RequestConfig config = clientContext.getRequestConfig(); final InetAddress local = config.getLocalAddress(); HttpHost proxy = config.getProxy(); final HttpHost target; if (host.getPort() > 0 && (host.getSchemeName().equalsIgnoreCase("http") && host.getPort() == 80 || host.getSchemeName().equalsIgnoreCase("https") && host.getPort() == 443)) { target = new HttpHost(host.getHostName(), -1, host.getSchemeName()); } else { target = host; } final boolean secure = target.getSchemeName().equalsIgnoreCase("https"); if (proxy == null) { return new HttpRoute(target, local, secure); } else { return new HttpRoute(target, local, proxy, secure); } }
@Override protected HttpHost determineProxy( final HttpHost target, final HttpRequest request, final HttpContext context) throws HttpException { if (noProxyFor(target.getHostName())) { return null; } return proxies.get(target.getSchemeName()); }
CredentialsProvider credsProvider = new BasicCredentialsProvider(); credsProvider.setCredentials( new AuthScope(targetHost.getHostName(), targetHost.getPort()), new UsernamePasswordCredentials("username", "password"));
String host = target.getHostName(); int port = target.getPort(); if (port < 0) { Scheme scheme = connManager.getSchemeRegistry(). getScheme(target.getSchemeName()); port = scheme.getDefaultPort();
static void parseTargetAddress(HttpRequestWrapper httpRequest, Span span) { if (span.isNoop()) return; HttpHost target = httpRequest.getTarget(); if (target == null) return; InetAddress address = target.getAddress(); if (address != null) { if (span.remoteIpAndPort(address.getHostAddress(), target.getPort())) return; } span.remoteIpAndPort(target.getHostName(), target.getPort()); }
try { targetUri = new URIBuilder() .setHost(target.getHostName()) .setPort(target.getPort()) .setScheme(target.getSchemeName()) .setPath(configuration.getPath()) .build();
static void parseTargetAddress(HttpRequestWrapper httpRequest, Span span) { if (span.isNoop()) return; HttpHost target = httpRequest.getTarget(); if (target == null) return; InetAddress address = target.getAddress(); if (address != null) { if (span.remoteIpAndPort(address.getHostAddress(), target.getPort())) return; } span.remoteIpAndPort(target.getHostName(), target.getPort()); } }
final Scheme schm = schemeRegistry.getScheme(target.getSchemeName()); if (!(schm.getSocketFactory() instanceof LayeredSocketFactory)) { throw new IllegalArgumentException try { sock = lsf.createSocket (conn.getSocket(), target.getHostName(), schm.resolvePort(target.getPort()), true); } catch (ConnectException ex) { throw new HttpHostConnectException(target, ex);
HttpHost targetHost = (HttpHost) context.getAttribute(ExecutionContext.HTTP_TARGET_HOST); if (authScheme != null) { Credentials creds = credsProvider.getCredentials(new AuthScope(targetHost.getHostName(), targetHost.getPort())); if (creds == null) { throw new HttpException("No credentials for preemptive authentication");
final Scheme schm = schemeRegistry.getScheme(target.getSchemeName()); final SocketFactory sf = schm.getSocketFactory(); final SocketFactory plain_sf; layered_sf = null; InetAddress[] addresses = InetAddress.getAllByName(target.getHostName()); Socket connsock = plain_sf.connectSocket(sock, addresses[i].getHostAddress(), schm.resolvePort(target.getPort()), local, 0, params); if (sock != connsock) { if (layered_sf != null) { Socket layeredsock = layered_sf.createSocket(sock, target.getHostName(), schm.resolvePort(target.getPort()), true); if (layeredsock != sock) {