|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--hamsam.net.HttpConnection
An HTTPConnection
connects to a specified host on a
specified port by establishing an HTTP/1.1 tunnel. This uses
HTTP CONNECT to create a persistent connection and uses that
to send and receive data.
SocksConnection
,
DirectConnection
Constructor Summary | |
HttpConnection(java.lang.String proxyHost,
int proxyPort,
java.lang.String host,
int port)
Construct an HTTP connection to the specified host and port through an HTTP 1.1 proxy. |
|
HttpConnection(java.lang.String proxyHost,
int proxyPort,
java.lang.String username,
java.lang.String password,
java.lang.String host,
int port)
Construct an HTTP connection to the specified host and port through an HTTP 1.1 proxy which requires authentication. |
Method Summary | |
int |
available()
Returns the number of bytes that can be read from this connection without blocking by the next caller of a method for this connection. |
void |
close()
Closes this connection and releases any resources associated with it. |
void |
flush()
Flushes this connection and forces any buffered output bytes to be written out. |
java.io.InputStream |
getInputStream()
Returns an InputStream that can be used to indirectly call the read methods. |
java.net.Socket |
getSocket()
Returns the socket used by this connection. |
int |
read()
Reads the next byte of data from the input stream. |
int |
read(byte[] b)
Reads some number of bytes from the connection and stores them into the buffer array b. |
int |
read(byte[] b,
int off,
int len)
Reads up to len bytes of data from the connection into an array of bytes. |
void |
write(byte[] b)
Writes b.length bytes from the specified byte array to this connection. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public HttpConnection(java.lang.String proxyHost, int proxyPort, java.lang.String host, int port) throws java.net.UnknownHostException, java.io.IOException
HttpConnection(proxyHost, proxyPort, username, password, host, port)
constructor.
proxyHost
- The HTTP proxy host nameproxyPort
- The HTTP proxy port numberhost
- The host name to be connected to.port
- The port number to be connected on.
java.net.UnknownHostException
- If the IP address of the host could not be determined.
java.io.IOException
- If an I/O error occurs when creating the connection.
java.lang.SecurityException
- If a security manager exists and its checkConnect
method doesn't allow the operation.public HttpConnection(java.lang.String proxyHost, int proxyPort, java.lang.String username, java.lang.String password, java.lang.String host, int port) throws java.net.UnknownHostException, java.io.IOException
HttpConnection(proxyHost, proxyPort, host, port)
constructor.
proxyHost
- The HTTP proxy host nameproxyPort
- The HTTP proxy port numberusername
- The username to connect to the proxy.password
- The password to connect to the proxy.host
- The host name to be connected to.port
- The port number to be connected on.
java.net.UnknownHostException
- If the IP address of the host could not be determined.
java.io.IOException
- If an I/O error occurs when creating the connection.
java.lang.SecurityException
- If a security manager exists and its checkConnect
method doesn't allow the operation.Method Detail |
public int available() throws java.io.IOException
This method has exactly the same semantics as that of
java.io.InputStream.available()
.
available
in interface Connection
java.io.IOException
- if an I/O error occurs.public int read() throws java.io.IOException
read
in interface Connection
java.io.IOException
- if an I/O error occurs.public int read(byte[] b) throws java.io.IOException
java.io.InputStream.read(byte[] b)
.
read
in interface Connection
b
- The buffer to which data is read.
java.io.IOException
- If an I/O error occurs.public int read(byte[] b, int off, int len) throws java.io.IOException
java.io.InputStream.read(byte[] b, int off, int len)
.
read
in interface Connection
b
- The buffer to which data is read.off
- The start offset in array b
at which data is written.len
- The maximum number of bytes to be read.
java.io.IOException
- If an I/O error occurs.public void write(byte[] b) throws java.io.IOException
write
in interface Connection
b
- The data to be sent through this connection.
java.io.IOException
- If an I/O error occurs.public void flush() throws java.io.IOException
flush
in interface Connection
java.io.IOException
- If an I/O error occurs.public void close() throws java.io.IOException
close
in interface Connection
java.io.IOException
- If an I/O error occurs.public java.io.InputStream getInputStream() throws java.io.IOException
getInputStream
in interface Connection
java.io.IOException
- If an I/O error occurs.public java.net.Socket getSocket() throws java.io.IOException
getSocket
in interface Connection
java.io.IOException
- If an I/O error occurs.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |