@Test public void testHTTPCLIENT_911() throws Exception{ Assert.assertEquals(new HttpHost("localhost"),URIUtils.extractHost(new URI("http: Assert.assertEquals(new HttpHost("localhost"),URIUtils.extractHost(new URI("http: Assert.assertEquals(new HttpHost("local_host"),URIUtils.extractHost(new URI("http: Assert.assertEquals(new HttpHost("local_host"),URIUtils.extractHost(new URI("http: Assert.assertEquals(new HttpHost("localhost",8),URIUtils.extractHost(new URI("http: Assert.assertEquals(new HttpHost("local_host",8),URIUtils.extractHost(new URI("http: Assert.assertEquals(new HttpHost("localhost"),URIUtils.extractHost(new URI("http: Assert.assertEquals(new HttpHost("local_host"),URIUtils.extractHost(new URI("http: Assert.assertEquals(new HttpHost("localhost",8080),URIUtils.extractHost(new URI("http: Assert.assertEquals(new HttpHost("local_host",8080),URIUtils.extractHost(new URI("http: Assert.assertEquals(new HttpHost("localhost",8080),URIUtils.extractHost(new URI("http: Assert.assertEquals(new HttpHost("local_host",8080),URIUtils.extractHost(new URI("http: }
public static HttpHost extractHost(final URI uri) { if (uri == null) { return null; } HttpHost target = null; if (uri.isAbsolute()) { int port = uri.getPort(); String host = uri.getHost(); if (host == null) { host = uri.getAuthority(); if (host != null) { int at = host.indexOf('@'); if (at >= 0) { if (host.length() > at+1 ) { host = host.substring(at+1); } else { host = null; } } if (host != null) { int colon = host.indexOf(':'); if (colon >= 0) { if (colon+1 < host.length()) { port = Integer.parseInt(host.substring(colon+1)); } host = host.substring(0,colon); } } } } String scheme = uri.getScheme(); if (host != null) { target = new HttpHost(host, port, scheme); } } return target; }
URIUtils { public static HttpHost extractHost(final URI uri) { if (uri == null) { return null; } HttpHost target = null; if (uri.isAbsolute()) { int port = uri.getPort(); String host = uri.getHost(); if (host == null) { host = uri.getAuthority(); if (host != null) { int at = host.indexOf('@'); if (at >= 0) { if (host.length() > at+1 ) { host = host.substring(at+1); } else { host = null; } } if (host != null) { int colon = host.indexOf(':'); if (colon >= 0) { if (colon+1 < host.length()) { port = Integer.parseInt(host.substring(colon+1)); } host = host.substring(0,colon); } } } } String scheme = uri.getScheme(); if (host != null) { target = new HttpHost(host, port, scheme); } } return target; } }
URIUtils { public static HttpHost extractHost(final URI uri) { if (uri == null) { return null; } HttpHost target = null; if (uri.isAbsolute()) { int port = uri.getPort(); String host = uri.getHost(); if (host == null) { host = uri.getAuthority(); if (host != null) { int at = host.indexOf('@'); if (at >= 0) { if (host.length() > at+1 ) { host = host.substring(at+1); } else { host = null; } } if (host != null) { int colon = host.indexOf(':'); if (colon >= 0) { if (colon+1 < host.length()) { port = Integer.parseInt(host.substring(colon+1)); } host = host.substring(0,colon); } } } } String scheme = uri.getScheme(); if (host != null) { target = new HttpHost(host, port, scheme); } } return target; } private  URIUtils(); }
URIUtils { public static HttpHost extractHost(final URI uri) { if (uri == null) { return null; } HttpHost target = null; if (uri.isAbsolute()) { int port = uri.getPort(); String host = uri.getHost(); if (host == null) { host = uri.getAuthority(); if (host != null) { int at = host.indexOf('@'); if (at >= 0) { if (host.length() > at+1 ) { host = host.substring(at+1); } else { host = null; } } if (host != null) { int colon = host.indexOf(':'); if (colon >= 0) { if (colon+1 < host.length()) { port = Integer.parseInt(host.substring(colon+1)); } host = host.substring(0,colon); } } } } String scheme = uri.getScheme(); if (host != null) { target = new HttpHost(host, port, scheme); } } return target; } private  URIUtils(); static URI createURI(
            final String scheme,
            final String host,
            int port,
            final String path,
            final String query,
            final String fragment); static URI rewriteURI(
            final URI uri,
            final HttpHost target,
            boolean dropFragment); static URI rewriteURI(
            final URI uri,
            final HttpHost target); static URI resolve(final URI baseURI, final String reference); static URI resolve(final URI baseURI, URI reference); static HttpHost extractHost(final URI uri); }
URIUtils { public static HttpHost extractHost(final URI uri) { if (uri == null) { return null; } HttpHost target = null; if (uri.isAbsolute()) { int port = uri.getPort(); String host = uri.getHost(); if (host == null) { host = uri.getAuthority(); if (host != null) { int at = host.indexOf('@'); if (at >= 0) { if (host.length() > at+1 ) { host = host.substring(at+1); } else { host = null; } } if (host != null) { int colon = host.indexOf(':'); if (colon >= 0) { if (colon+1 < host.length()) { port = Integer.parseInt(host.substring(colon+1)); } host = host.substring(0,colon); } } } } String scheme = uri.getScheme(); if (host != null) { target = new HttpHost(host, port, scheme); } } return target; } private  URIUtils(); static URI createURI(
            final String scheme,
            final String host,
            int port,
            final String path,
            final String query,
            final String fragment); static URI rewriteURI(
            final URI uri,
            final HttpHost target,
            boolean dropFragment); static URI rewriteURI(
            final URI uri,
            final HttpHost target); static URI resolve(final URI baseURI, final String reference); static URI resolve(final URI baseURI, URI reference); static HttpHost extractHost(final URI uri);  }