rabbit.io
Class WebConnection

java.lang.Object
  extended by rabbit.io.WebConnection

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, boolean isProxyConnected, java.lang.String proxyAuth, Counter counter, Logger logger, NLSOHandler handler)
          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.
protected  java.nio.channels.SocketChannel getChannel()
           
 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.
protected  java.nio.channels.SelectionKey getSelectionKey()
           
 boolean getWaiting()
           
 void setPipeline(boolean p)
           
 void setReleased()
          Mark this WebConnection as released at current time.
 void setReleased(java.util.Date d)
          Mark this WebConnection as released at given time.
protected  void setSelectionKey(java.nio.channels.SelectionKey sk)
           
 void writeHTTPHeader(HTTPHeader header)
          Write an HTTP header on this connection.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

WebConnection

public WebConnection(java.net.InetAddress ia,
                     int port,
                     boolean isProxyConnected,
                     java.lang.String proxyAuth,
                     Counter counter,
                     Logger logger,
                     NLSOHandler handler)
              throws java.io.IOException
Create a new WebConnection to the given InetAddress and port.

Parameters:
ia - the computer to connect to.
port - the port number to connect to.
Throws:
java.io.IOException
Method Detail

close

public void close()
Close the connection.


setPipeline

public void setPipeline(boolean p)

getWaiting

public boolean getWaiting()

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.


setSelectionKey

protected void setSelectionKey(java.nio.channels.SelectionKey sk)

getSelectionKey

protected java.nio.channels.SelectionKey getSelectionKey()

getChannel

protected java.nio.channels.SocketChannel getChannel()

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()
                                   throws java.io.IOException
Get the last chunked page.

Returns:
an InputStream to the last chunked page.
Throws:
java.io.IOException

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 - if an I/O error occurs.