rabbit.io
Class WebConnection

java.lang.Object
  extended byrabbit.io.WebConnection
Direct Known Subclasses:
AppHereWebConnection

public class WebConnection
extends java.lang.Object

A class to handle a connection to the Internet.


Constructor Summary
WebConnection(java.net.InetAddress ia, int port)
          Create a new WebConnection to the given InetAddress and port.
 
Method Summary
 boolean chunked()
          Is this request chunked?
 void close()
          Close the connection.
 long dataSize()
          Get the size of the data being fetched.
 java.io.InputStream getChunkStream()
          Get the last chunked page.
 java.net.InetAddress getInetAddress()
          Get the InetAddress that this WebConnection is connected to.
 HTTPInputStream getInputStream()
          Get the InputStream.
 boolean getKeepAlive()
          Get the keepalive value of this WebConnection.
 HTTPOutputStream getOutputStream()
          Get the OutputStream of this WebConnection.
 int getPort()
          Get the port number this WebConnection is connected to.
 java.util.Date getReleasedAt()
          Get the time that this WebConnection was released.
 void setReleased()
          Mark this WebConnection as released at current time.
 void setReleased(java.util.Date d)
          Mark this WebConnection as released at given time.
 void writeHTTPHeader(HTTPHeader header)
          Write an HTTP header on this connection.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

WebConnection

public WebConnection(java.net.InetAddress ia,
                     int port)
              throws java.io.IOException
Create a new WebConnection to the given InetAddress and port.

Parameters:
port - the port number to connect to.
Method Detail

close

public void close()
Close the connection.


getInetAddress

public java.net.InetAddress getInetAddress()
Get the InetAddress that this WebConnection is connected to.

Returns:
the InetAddress.

getPort

public int getPort()
Get the port number this WebConnection is connected to.

Returns:
the port number.

setReleased

public void setReleased()
Mark this WebConnection as released at current time.


setReleased

public void setReleased(java.util.Date d)
Mark this WebConnection as released at given time.

Parameters:
d - the time that this WebConnection is released.

getReleasedAt

public java.util.Date getReleasedAt()
Get the time that this WebConnection was released.


getInputStream

public HTTPInputStream getInputStream()
Get the InputStream.

Returns:
an HTTPInputStream.

getOutputStream

public HTTPOutputStream getOutputStream()
Get the OutputStream of this WebConnection.

Returns:
an HTTPOutputStream.

getKeepAlive

public boolean getKeepAlive()
Get the keepalive value of this WebConnection.

Returns:
true if this WebConnection may be reused.

dataSize

public long dataSize()
Get the size of the data being fetched.

Returns:
the number of bytes of the page or -1 if unknown.

chunked

public boolean chunked()
Is this request chunked?

Returns:
true if the last read request was chunked, false otherwise.

getChunkStream

public java.io.InputStream getChunkStream()
Get the last chunked page.

Returns:
an InputStream to the last chunked page.

writeHTTPHeader

public void writeHTTPHeader(HTTPHeader header)
                     throws java.io.IOException
Write an HTTP header on this connection. This is a convenience function to do HTTPOutputStream hos = getOutputStream (); hos.writeHTTPHeader (header);

Parameters:
header - the Header to write.
Throws:
java.io.IOException