Code example for HttpHost

Methods: getHostNamegetPortgetSchemeName

0
        new BasicConnPool((BasicConnFactory) null); 
    } 
 
    @Test 
    public void testHttpCreateConnection() throws Exception { 
        host = new HttpHost("localhost", serverPort, "http");
        conn = connFactory.create(host);
 
        assertTrue(conn.isOpen());
        assertEquals(100, conn.getSocketTimeout());
    } 
 
    @Test 
    public void testHttpsCreateConnection() throws Exception { 
        final SocketConfig sconfig = SocketConfig.custom().setSoTimeout(100).build();
        connFactory = new BasicConnFactory(
                null, 
                (SSLSocketFactory)SSLSocketFactory.getDefault(),
                0, sconfig, ConnectionConfig.DEFAULT);
        host = new HttpHost("localhost", sslServerPort, "https");
        conn = connFactory.create(host);
 
        assertTrue(conn.isOpen());
        assertEquals(100, conn.getSocketTimeout());
    } 
 
    @Test 
    public void testHttpCreateEntry() throws Exception { 
        host = new HttpHost("localhost", serverPort, "http");
        conn = connFactory.create(host);
 
        final BasicPoolEntry entry = pool.createEntry(host, conn);
 
        assertEquals(conn, entry.getConnection());
        assertEquals("localhost", entry.getRoute().getHostName());
 
        entry.close();
    } 
 
} 
Stop searching for code, let great code find you!  Add Codota to your java IDE