HttpHost getHostName - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for HttpHost getHostName method.

This code example shows how to use the following methods:getHostName, getPort, toHostString
            HttpHost host = (HttpHost) context.getAttribute(key);
            if (host == null) {
                throw new AuthenticationException("Authentication host is not set " + "in the execution context");
            } 
            String authServer;
            if (!this.stripPort && host.getPort() > 0) {
                authServer = host.toHostString();
            } else { 
                authServer = host.getHostName();
            } 
 
            if (LOGGER.isDebugEnabled()) { 
                LOGGER.debug("init " + authServer);
            } 
            final Oid negotiationOid = new Oid(SPNEGO_OID);
 
            final GSSManager manager = GSSManager.getInstance();
            final GSSName serverName = manager.createName("HTTP@" + authServer, GSSName.NT_HOSTBASED_SERVICE);
            final GSSContext gssContext = manager.createContext(serverName.canonicalize(negotiationOid), negotiationOid, null,
                    DEFAULT_LIFETIME);
8
CodeRank
This code example shows how to use the following methods:getHostName, getPort, getSchemeName
        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();
    } 
 
} 

7
CodeRank
This code example shows how to use the following methods:getHostName
        final String[] subjectAlts) throws SSLException {
        if (this.proxy == null) {
            super.verify(host, cns, subjectAlts, true);
            return; 
        } 
        log.debug("Proxy: {}", proxy);
        if (!host.equals(proxy.getHostName())) {
            super.verify(host, cns, subjectAlts, true);
        } 
    } 
 
    @Override 
    public final String toString() {
        return "LANTERN VERIFIER"; 
    } 
 
} 
 
7
CodeRank
This code example shows how to use the following methods:getHostName, getPort
This code example shows how to use the following methods:getHostName, getPort, getSchemeName
        conn.bind(socket);
        return conn;
    } 
 
    public HttpClientConnection create(final HttpHost host) throws IOException {
        final String scheme = host.getSchemeName();
        Socket socket = null;
        if ("http".equalsIgnoreCase(scheme)) {
            socket = this.plainfactory != null ? this.plainfactory.createSocket() :
                    new Socket();
        } if ("https".equalsIgnoreCase(scheme)) {
            socket = (this.sslfactory != null ? this.sslfactory :
                    SSLSocketFactory.getDefault()).createSocket();
        } 
        if (socket == null) {
            throw new IOException(scheme + " scheme is not supported");
        } 
        final String hostname = host.getHostName();
        int port = host.getPort();
        if (port == -1) {

6
CodeRank
This code example shows how to use the following methods:getHostName, getPort
        return new LoggingBHttpClientConnection(8 * 1024); 
    } 
 
    public void connect(final HttpHost host, final DefaultBHttpClientConnection conn) throws IOException {
        final Socket socket = new Socket();
        socket.connect(new InetSocketAddress(host.getHostName(), host.getPort()), this.timeout);
        conn.bind(socket);
        conn.setSocketTimeout(this.timeout);
    } 
 
    public HttpResponse execute(
            final HttpRequest request,
            final HttpHost targetHost,
            final HttpClientConnection conn) throws HttpException, IOException {
        this.context.setTargetHost(targetHost);
        this.httpexecutor.preProcess(request, this.httpproc, this.context);
        final HttpResponse response = this.httpexecutor.execute(request, conn, this.context);
        this.httpexecutor.postProcess(response, this.httpproc, this.context);
        return response;
    } 
5
CodeRank
This code example shows how to use the following methods:getHostName, getPort
     * @deprecated (4.3) use {@link SocketAddressResolver} 
     */ 
    @Deprecated 
    @Override 
    protected SocketAddress resolveRemoteAddress(final HttpHost host) {
        return new InetSocketAddress(host.getHostName(), host.getPort());
    } 
 
    /** 
     * @deprecated (4.3) use {@link SocketAddressResolver} 
     */ 
    @Deprecated 
    @Override 
    protected SocketAddress resolveLocalAddress(final HttpHost host) {
        return null; 
    } 
 
    @Override 
    protected BasicNIOPoolEntry createEntry(final HttpHost host, final NHttpClientConnection conn) {
        final BasicNIOPoolEntry entry = new BasicNIOPoolEntry(
5
CodeRank
This code example shows how to use the following methods:getHostName, getPort, toHostString
                if (host == null) {
                    throw new AuthenticationException("Authentication host is not set " +
                            "in the execution context"); 
                } 
                String authServer;
                if (!this.stripPort && host.getPort() > 0) {
                    authServer = host.toHostString();
                } else { 
                    authServer = host.getHostName();
                } 
 
                if (log.isDebugEnabled()) {
                    log.debug("init " + authServer);
                } 
                token = generateToken(token, authServer);
                state = State.TOKEN_GENERATED;
            } catch (GSSException gsse) {
                state = State.FAILED;
                if (gsse.getMajor() == GSSException.DEFECTIVE_CREDENTIAL
                        || gsse.getMajor() == GSSException.CREDENTIALS_EXPIRED)
5
CodeRank
This code example shows how to use the following methods:getHostName, getPort
This code example shows how to use the following methods:getHostName, getPort
	 * @param password 
	 */ 
	public RestClient(final String username, final String password) {
		this(); 
		httpClient.getCredentialsProvider().setCredentials(
				new AuthScope(targetHost.getHostName(), targetHost.getPort()),
				new UsernamePasswordCredentials(username, password));
 
	} 
 
	public UserDTO createAccount(final String email, final String name, final String description) throws Exception {
		final Map<String, String> params = new HashMap<String, String>();
		params.put("email", email);
		params.put("name", name);
		params.put("description", description);
		return queryServerPost(Constants.REST_PATH + "/account/create", params, new UserDTO());
	} 
 
	public UserDTO resetAccountPassword(final String email) throws Exception {
		final Map<String, String> params = new HashMap<String, String>();
4
CodeRank

Related HttpHost getHostName Questions & Answers:

getHostName Method Overview
Returns the host name.
See Code Examples for other Android HttpHost Methods: