public final class

HttpHost

extends Object
implements Serializable Cloneable
java.lang.Object
   ↳ org.apache.http.HttpHost

Class Overview

Holds all of the variables needed to describe an HTTP connection to a host. This includes remote host name, port and scheme.

Summary

Constants
String DEFAULT_SCHEME_NAME The default scheme is "http".
Fields
protected final String hostname The host to use.
protected final String lcHostname The lowercase host, for equals(Object) and hashCode().
protected final int port The port to use.
protected final String schemeName The scheme
Public Constructors
HttpHost(String hostname, int port, String scheme)
Creates a new HttpHost, specifying all values.
HttpHost(String hostname, int port)
Creates a new HttpHost, with default scheme.
HttpHost(String hostname)
Creates a new HttpHost, with default scheme and port.
HttpHost(HttpHost httphost)
Copy constructor for HttpHost.
Public Methods
Object clone()
boolean equals(Object obj)
String getHostName()
Returns the host name.
int getPort()
Returns the port.
String getSchemeName()
Returns the scheme name.
int hashCode()
String toHostString()
Obtains the host string, without scheme prefix.
String toString()
String toURI()
Return the host URI, as a string.
[Expand]
Inherited Methods
From class java.lang.Object

Constants

public static final String DEFAULT_SCHEME_NAME

The default scheme is "http".

Constant Value: "http"

Fields

protected final String hostname

The host to use.

protected final String lcHostname

The lowercase host, for equals(Object) and hashCode().

protected final int port

The port to use.

protected final String schemeName

The scheme

Public Constructors

public HttpHost (String hostname, int port, String scheme)

Creates a new HttpHost, specifying all values. Constructor for HttpHost.

Parameters
hostname the hostname (IP or DNS name)
port the port number. -1 indicates the scheme default port.
scheme the name of the scheme. null indicates the default scheme

public HttpHost (String hostname, int port)

Creates a new HttpHost, with default scheme.

Parameters
hostname the hostname (IP or DNS name)
port the port number. -1 indicates the scheme default port.

public HttpHost (String hostname)

Creates a new HttpHost, with default scheme and port.

Parameters
hostname the hostname (IP or DNS name)

public HttpHost (HttpHost httphost)

Copy constructor for HttpHost.

Parameters
httphost the HTTP host to copy details from

Public Methods

public Object clone ()

public boolean equals (Object obj)

public String getHostName ()

Returns the host name.

Returns
  • the host name (IP or DNS name)

public int getPort ()

Returns the port.

Returns
  • the host port, or -1 if not set

public String getSchemeName ()

Returns the scheme name.

Returns
  • the scheme name

public int hashCode ()

See Also

public String toHostString ()

Obtains the host string, without scheme prefix.

Returns
  • the host string, for example localhost:8080

public String toString ()

public String toURI ()

Return the host URI, as a string.

Returns
  • the host URI