Package org.apache.http.conn.scheme

Examples of org.apache.http.conn.scheme.Scheme.resolvePort()


     * @throws Exception in case of a problem
     */
    protected DefaultHttpClientConnection connectTo(HttpHost target, HttpParams params) throws Exception {

        Scheme schm = supportedSchemes.get(target.getSchemeName());
        int port = schm.resolvePort(target.getPort());

        DefaultHttpClientConnection conn = new DefaultHttpClientConnection();
        InetSocketAddress address = new InetSocketAddress(InetAddress.getByName(target.getHostName()), port);
        Socket sock = schm.getSchemeSocketFactory().connectSocket(null, address, null, params);
        conn.bind(sock, params);
View Full Code Here


            long start = System.currentTimeMillis();
            InetAddress[] addresses = resolveHostname(target.getHostName());
            // long dnsEnd = System.nanoTime();
            long dnsEnd = System.currentTimeMillis();

            int port = schm.resolvePort(target.getPort());
            for (int i = 0; i < addresses.length; i++) {
                InetAddress address = addresses[i];
                boolean last = i == addresses.length - 1;

                Socket sock = sf.createSocket(params);
View Full Code Here

                final SchemeRegistry schemeRegistry = (SchemeRegistry) context.getAttribute(
                        ClientContext.SCHEME_REGISTRY);
                if (target.getPort() < 0) {
                    final Scheme scheme = schemeRegistry.getScheme(target);
                    target = new HttpHost(target.getHostName(),
                            scheme.resolvePort(target.getPort()), target.getSchemeName());
                }
                if (authCache == null) {
                    authCache = new BasicAuthCache();
                    context.setAttribute(ClientContext.AUTH_CACHE, authCache);
                }
View Full Code Here

    if (paramOperatedClientConnection.isOpen())
      throw new IllegalStateException("Connection must not be open");
    Scheme localScheme = this.schemeRegistry.getScheme(paramHttpHost.getSchemeName());
    SchemeSocketFactory localSchemeSocketFactory = localScheme.getSchemeSocketFactory();
    InetAddress[] arrayOfInetAddress = resolveHostname(paramHttpHost.getHostName());
    int i = localScheme.resolvePort(paramHttpHost.getPort());
    for (int j = 0; j < arrayOfInetAddress.length; j++)
    {
      InetAddress localInetAddress = arrayOfInetAddress[j];
      int k = j == arrayOfInetAddress.length - 1 ? 1 : 0;
      Object localObject = localSchemeSocketFactory.createSocket(paramHttpParams);
View Full Code Here

   
    public void testResolvePort() {
        Scheme http = new Scheme
            ("http", PlainSocketFactory.getSocketFactory(), 80);

        assertEquals(8080, http.resolvePort(8080));
        assertEquals(80, http.resolvePort(-1));
    }
   
    public void testHashCode() {
        Scheme http = new Scheme
View Full Code Here

    protected DefaultHttpClientConnection connectTo(HttpHost target,
                                                    HttpParams params)
        throws Exception {

        Scheme schm = supportedSchemes.get(target.getSchemeName());
        int port = schm.resolvePort(target.getPort());

        DefaultHttpClientConnection conn = new DefaultHttpClientConnection();
        Socket sock = schm.getSocketFactory().connectSocket
            (null, target.getHostName(), port, null, 0, params);
        conn.bind(sock, params);
View Full Code Here

    public void testResolvePort() {
        Scheme http = new Scheme
            ("http", PlainSocketFactory.getSocketFactory(), 80);

        assertEquals(8080, http.resolvePort(8080));
        assertEquals(80, http.resolvePort(-1));
    }
   
    public void testHashCode() {
        Scheme http = new Scheme
            ("http", PlainSocketFactory.getSocketFactory(), 80);
View Full Code Here

            // Obtain the scheme registry
            SchemeRegistry sr = (SchemeRegistry) context.getAttribute(
                    ClientContext.SCHEME_REGISTRY);
            if (sr != null) {
                Scheme scheme = sr.get(targetHost.getSchemeName());
                port = scheme.resolvePort(port);
            } else {
                port = conn.getRemotePort();
            }
        }
       
View Full Code Here

        Socket sock = sf.createSocket();
        conn.opening(sock, target);

        try {
            sock = sf.connectSocket(sock, target.getHostName(),
                    schm.resolvePort(target.getPort()),
                    local, 0, params);
        } catch (ConnectException ex) {
            throw new HttpHostConnectException(target, ex);
        }
        prepareSocket(sock, context, params);
View Full Code Here

        final SchemeRegistry registry = getSchemeRegistry(context);
        final Scheme schm = registry.getScheme(target.getSchemeName());
        final SchemeSocketFactory sf = schm.getSchemeSocketFactory();

        final InetAddress[] addresses = resolveHostname(target.getHostName());
        final int port = schm.resolvePort(target.getPort());
        for (int i = 0; i < addresses.length; i++) {
            final InetAddress address = addresses[i];
            final boolean last = i == addresses.length - 1;

            Socket sock = sf.createSocket(params);
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.