/** * Creates {@code HttpHost} instance with the given scheme, hostname and port. * * @param hostname the hostname (IP or DNS name) * @param port the port number. * {@code -1} indicates the scheme default port. * @param scheme the name of the scheme. * {@code null} indicates the * {@link #DEFAULT_SCHEME_NAME default scheme} */ public HttpHost(final String hostname, final int port, final String scheme) { super(); this.hostname = Args.containsNoBlanks(hostname, "Host name"); this.lcHostname = hostname.toLowerCase(Locale.ROOT); if (scheme != null) { this.schemeName = scheme.toLowerCase(Locale.ROOT); } else { this.schemeName = DEFAULT_SCHEME_NAME; } this.port = port; this.address = null; }
/** * Creates {@code HttpHost} instance with the given scheme, hostname and port. * * @param hostname the hostname (IP or DNS name) * @param port the port number. * {@code -1} indicates the scheme default port. * @param scheme the name of the scheme. * {@code null} indicates the * {@link #DEFAULT_SCHEME_NAME default scheme} */ public HttpHost(final String hostname, final int port, final String scheme) { super(); this.hostname = Args.containsNoBlanks(hostname, "Host name"); this.lcHostname = hostname.toLowerCase(Locale.ROOT); if (scheme != null) { this.schemeName = scheme.toLowerCase(Locale.ROOT); } else { this.schemeName = DEFAULT_SCHEME_NAME; } this.port = port; this.address = null; }
/** * Creates {@code HttpHost} instance with the given scheme, hostname and port. * * @param hostname the hostname (IP or DNS name) * @param port the port number. * {@code -1} indicates the scheme default port. * @param scheme the name of the scheme. * {@code null} indicates the * {@link #DEFAULT_SCHEME_NAME default scheme} */ public HttpHost(final String hostname, final int port, final String scheme) { super(); this.hostname = Args.containsNoBlanks(hostname, "Host name"); this.lcHostname = hostname.toLowerCase(Locale.ROOT); if (scheme != null) { this.schemeName = scheme.toLowerCase(Locale.ROOT); } else { this.schemeName = DEFAULT_SCHEME_NAME; } this.port = port; this.address = null; }
/** * Creates {@code HttpHost} instance with the given scheme, hostname and port. * * @param hostname the hostname (IP or DNS name) * @param port the port number. * {@code -1} indicates the scheme default port. * @param scheme the name of the scheme. * {@code null} indicates the * {@link #DEFAULT_SCHEME_NAME default scheme} */ public HttpHost(final String hostname, final int port, final String scheme) { super(); this.hostname = Args.containsNoBlanks(hostname, "Host name"); this.lcHostname = hostname.toLowerCase(Locale.ROOT); if (scheme != null) { this.schemeName = scheme.toLowerCase(Locale.ROOT); } else { this.schemeName = DEFAULT_SCHEME_NAME; } this.port = port; this.address = null; }
/** * Creates {@code HttpHost} instance from string. Text may not contain any blanks. * * @since 4.4 */ public static HttpHost create(final String s) { Args.containsNoBlanks(s, "HTTP Host"); String text = s; String scheme = null; final int schemeIdx = text.indexOf("://"); if (schemeIdx > 0) { scheme = text.substring(0, schemeIdx); text = text.substring(schemeIdx + 3); } int port = -1; final int portIdx = text.lastIndexOf(":"); if (portIdx > 0) { try { port = Integer.parseInt(text.substring(portIdx + 1)); } catch (NumberFormatException ex) { throw new IllegalArgumentException("Invalid HTTP host: " + text); } text = text.substring(0, portIdx); } return new HttpHost(text, port, scheme); }
/** * Creates {@code HttpHost} instance from string. Text may not contain any blanks. * * @since 4.4 */ public static HttpHost create(final String s) { Args.containsNoBlanks(s, "HTTP Host"); String text = s; String scheme = null; final int schemeIdx = text.indexOf("://"); if (schemeIdx > 0) { scheme = text.substring(0, schemeIdx); text = text.substring(schemeIdx + 3); } int port = -1; final int portIdx = text.lastIndexOf(":"); if (portIdx > 0) { try { port = Integer.parseInt(text.substring(portIdx + 1)); } catch (final NumberFormatException ex) { throw new IllegalArgumentException("Invalid HTTP host: " + text); } text = text.substring(0, portIdx); } return new HttpHost(text, port, scheme); }
/** * Creates {@code HttpHost} instance from string. Text may not contain any blanks. * * @since 4.4 */ public static HttpHost create(final String s) { Args.containsNoBlanks(s, "HTTP Host"); String text = s; String scheme = null; final int schemeIdx = text.indexOf("://"); if (schemeIdx > 0) { scheme = text.substring(0, schemeIdx); text = text.substring(schemeIdx + 3); } int port = -1; final int portIdx = text.lastIndexOf(":"); if (portIdx > 0) { try { port = Integer.parseInt(text.substring(portIdx + 1)); } catch (NumberFormatException ex) { throw new IllegalArgumentException("Invalid HTTP host: " + text); } text = text.substring(0, portIdx); } return new HttpHost(text, port, scheme); }
/** * Creates {@code HttpHost} instance from string. Text may not contain any blanks. * * @since 4.4 */ public static HttpHost create(final String s) { Args.containsNoBlanks(s, "HTTP Host"); String text = s; String scheme = null; final int schemeIdx = text.indexOf("://"); if (schemeIdx > 0) { scheme = text.substring(0, schemeIdx); text = text.substring(schemeIdx + 3); } int port = -1; final int portIdx = text.lastIndexOf(":"); if (portIdx > 0) { try { port = Integer.parseInt(text.substring(portIdx + 1)); } catch (NumberFormatException ex) { throw new IllegalArgumentException("Invalid HTTP host: " + text); } text = text.substring(0, portIdx); } return new HttpHost(text, port, scheme); }