Example usage for org.apache.http.nio.conn.scheme AsyncSchemeRegistry getScheme

List of usage examples for org.apache.http.nio.conn.scheme AsyncSchemeRegistry getScheme

Introduction

In this page you can find the example usage for org.apache.http.nio.conn.scheme AsyncSchemeRegistry getScheme.

Prototype

public final AsyncScheme getScheme(final HttpHost host) 

Source Link

Document

Obtains the scheme for a host.

Usage

From source file:org.apache.http.impl.nio.client.DefaultAsyncRequestDirector.java

private HttpRequest createConnectRequest(final HttpRoute route) {
    // see RFC 2817, section 5.2 and
    // INTERNET-DRAFT: Tunneling TCP based protocols through
    // Web proxy servers
    final HttpHost target = route.getTargetHost();
    final String host = target.getHostName();
    int port = target.getPort();
    if (port < 0) {
        final AsyncSchemeRegistry registry = getSchemeRegistry(this.localContext);
        final AsyncScheme scheme = registry.getScheme(target.getSchemeName());
        port = scheme.getDefaultPort();//from ww  w  .  j  ava 2 s. com
    }
    final StringBuilder buffer = new StringBuilder(host.length() + 6);
    buffer.append(host);
    buffer.append(':');
    buffer.append(Integer.toString(port));
    final ProtocolVersion ver = HttpProtocolParams.getVersion(this.params);
    final HttpRequest req = new BasicHttpRequest("CONNECT", buffer.toString(), ver);
    return req;
}