public static Address from(String hostAndPort) { String host; int port; int colon = hostAndPort.indexOf(':'); if (colon >= 0) { host = hostAndPort.substring(0, colon); port = Integer.parseInt(hostAndPort.substring(colon + 1)); } else { host = hostAndPort; port = 0; } return new Address(host, port); }
public void send( final ResourceExchange exchange ) { try { StringBuilder urlBuilder = new StringBuilder(); urlBuilder.append( exchange.getScheme().toString() ); urlBuilder.append( "://" ); urlBuilder.append( exchange.getAddress().toString() ); urlBuilder.append( exchange.getURI().replace( "//", "/" ) ); URL url = new URL( urlBuilder.toString() ); String method = exchange.getMethod(); setupConnection( url ); if ( method.equalsIgnoreCase( "GET" ) ) { doGet( url, exchange, true ); } else if ( method.equalsIgnoreCase( "HEAD" ) ) { doGet( url, exchange, false ); } closeConnection(); } catch ( Exception e ) { } }
@Override public String getProxyHost() { return getProxy().getHost(); }
@Override public int getProxyPort() { return getProxy().getPort(); }
channel.socket().connect(address.toSocketAddress(), _httpClient.getConnectTimeout()); channel.configureBlocking(false); _selectorManager.register( channel, destination ); channel.connect(address.toSocketAddress()); _selectorManager.register(channel,destination); ConnectTimeout connectTimeout = new ConnectTimeout(channel,destination);
public ConnectExchange(Address serverAddress, SelectConnector.UpgradableEndPoint proxyEndPoint) { this.proxyEndPoint = proxyEndPoint; setMethod(HttpMethods.CONNECT); String serverHostAndPort = serverAddress.toString(); setRequestURI(serverHostAndPort); addRequestHeader(HttpHeaders.HOST, serverHostAndPort); addRequestHeader(HttpHeaders.PROXY_CONNECTION, "keep-alive"); addRequestHeader(HttpHeaders.USER_AGENT, "Jetty-Client"); }
public HttpDestination getDestination(Address remote, boolean ssl, SslContextFactory sslContextFactory) throws IOException { if (remote == null) throw new UnknownHostException("Remote socket address cannot be null."); HttpDestination destination = _destinations.get(remote); if (destination == null) { destination = new HttpDestination(this, remote, ssl, sslContextFactory); if (_proxy != null && (_noProxy == null || !_noProxy.contains(remote.getHost()))) { destination.setProxy(_proxy); if (_proxyAuthentication != null) destination.setProxyAuthentication(_proxyAuthentication); } HttpDestination other =_destinations.putIfAbsent(remote, destination); if (other!=null) destination=other; } return destination; }
socket.connect(address.toSocketAddress(), _httpClient.getConnectTimeout());
public void setProxy(String host, int port) { setProxy(new org.eclipse.jetty.client.Address(host, port)); }
public String getUrl() { String params = ce.getRequestFields().getStringField(HttpHeaders.CONTENT_ENCODING); return ce.getScheme() + "://" + ce.getAddress().toString() + ce.getRequestURI() + (params != null ? "?" + params : ""); }
/** * @param uri * an absolute URI (for example 'http://localhost/foo/bar?a=1') */ public void setURI(URI uri) { if (!uri.isAbsolute()) throw new IllegalArgumentException("!Absolute URI: " + uri); if (uri.isOpaque()) throw new IllegalArgumentException("Opaque URI: " + uri); if (LOG.isDebugEnabled()) LOG.debug("URI = {}",uri.toASCIIString()); String scheme = uri.getScheme(); int port = uri.getPort(); if (port <= 0) port = "https".equalsIgnoreCase(scheme)?443:80; setScheme(scheme); setAddress(new Address(uri.getHost(),port)); HttpURI httpUri = new HttpURI(uri); String completePath = httpUri.getCompletePath(); setRequestURI(completePath == null?"/":completePath); }
HttpDestination(HttpClient client, Address address, boolean ssl, SslContextFactory sslContextFactory) { _client = client; _address = address; _ssl = ssl; _sslContextFactory = sslContextFactory; _maxConnections = _client.getMaxConnectionsPerAddress(); _maxQueueSize = _client.getMaxQueueSizePerAddress(); String addressString = address.getHost(); if (address.getPort() != (_ssl ? 443 : 80)) addressString += ":" + address.getPort(); _hostHeader = new ByteArrayBuffer(addressString); }
exch.setAddress(new Address(host, port)); exch.setURI(getRequestURI()); try {
exch.setAddress(new Address(host, port)); exch.setURI(getRequestURI()); try {
void associate(AbstractHttpConnection connection) { if (connection.getEndPoint().getLocalAddr() != null) _localAddress = new Address(connection.getEndPoint().getLocalAddr(),connection.getEndPoint().getLocalPort()); _connection = connection; if (getStatus() == STATUS_CANCELLING) abort(); }
httpClient.setProxy( new Address( proxyInfo.getHost(), proxyInfo.getPort() ) );