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 static int extracPort(HttpHost target) { if (target.getPort() > 0) { return target.getPort(); } if (target.getSchemeName().equalsIgnoreCase("http")) { return 80; } else if (target.getSchemeName().equalsIgnoreCase("https")) { return 443; } return target.getPort(); } }
/** * 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();
public int resolve(final HttpHost host) throws UnsupportedSchemeException { Args.notNull(host, "HTTP host"); final int port = host.getPort(); if (port > 0) { return port; } final String name = host.getSchemeName(); if (name.equalsIgnoreCase("http")) { return 80; } else if (name.equalsIgnoreCase("https")) { return 443; } else { throw new UnsupportedSchemeException(name + " protocol is not supported"); } }
@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); } } } }
@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); } }
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()); }
target.getSchemeName(), target.getHostName(), target.getPort(), uri.getRawPath(), uri.getRawQuery(),
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()); } }
String host = target.getHostName(); int port = target.getPort(); if (port < 0) { Scheme scheme = connManager.getSchemeRegistry(). getScheme(target.getSchemeName()); port = scheme.getDefaultPort();
CredentialsProvider credsProvider = new BasicCredentialsProvider(); credsProvider.setCredentials( new AuthScope( target.getHostName(), target.getPort() ), new UsernamePasswordCredentials( user, password ) );
try { targetUri = new URIBuilder() .setHost(target.getHostName()) .setPort(target.getPort()) .setScheme(target.getSchemeName()) .setPath(configuration.getPath()) .build();
CredentialsProvider credsProvider = new BasicCredentialsProvider(); credsProvider.setCredentials( new AuthScope(targetHost.getHostName(), targetHost.getPort()), new UsernamePasswordCredentials("username", "password"));
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) {
py = new Proxy(Proxy.Type.HTTP, new InetSocketAddress(proxy.getHostName(), proxy.getPort())); }else if(proxyHandle != null){ py = proxyHandle.makeProxy(this);
@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; } }