org.mortbay.http
Class HttpTunnel

java.lang.Object
  extended byorg.mortbay.http.HttpTunnel

public class HttpTunnel
extends java.lang.Object

HTTP Tunnel. A HTTP Tunnel can be used to take over a HTTP connection in order to tunnel another protocol over it. The prime example is the CONNECT method handled by the ProxyHandler to setup a SSL tunnel between the client and the real server.

Version:
$Revision: 1.11 $
Author:
Greg Wilkins (gregw)
See Also:
HttpConnection

Constructor Summary
HttpTunnel(java.net.Socket socket, java.io.InputStream in, java.io.OutputStream out)
          Constructor.
 
Method Summary
static int copyBytes(java.io.InputStream in, java.io.OutputStream out, long byteCount)
          Copy Stream in to Stream for byteCount bytes or until EOF or exception.
 java.net.Socket getSocket()
           
 int getTimeoutMs()
           
 void handle(java.io.InputStream in, java.io.OutputStream out)
          handle method.
 void setTimeoutMs(int timeoutMs)
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

HttpTunnel

public HttpTunnel(java.net.Socket socket,
                  java.io.InputStream in,
                  java.io.OutputStream out)
           throws java.io.IOException
Constructor.

Parameters:
socket - The tunnel socket.
in - Alternative input stream or null if using normal socket stream
out - Alternative output stream or null if using normal socket stream
Throws:
java.io.IOException
Method Detail

handle

public void handle(java.io.InputStream in,
                   java.io.OutputStream out)
handle method. This method is called by the HttpConnection.handleNext() method if this HttpTunnel has been set on that connection. The default implementation of this method copies between the HTTP socket and the socket passed in the constructor.

Parameters:
in -
out -

copyBytes

public static int copyBytes(java.io.InputStream in,
                            java.io.OutputStream out,
                            long byteCount)
                     throws java.io.IOException
Copy Stream in to Stream for byteCount bytes or until EOF or exception.

Returns:
Copied bytes count or -1 if no bytes were read *and* EOF was reached
Throws:
java.io.IOException

getSocket

public java.net.Socket getSocket()
Returns:
Returns the socket.

getTimeoutMs

public int getTimeoutMs()
Returns:
Returns the timeoutMs.

setTimeoutMs

public void setTimeoutMs(int timeoutMs)
Parameters:
timeoutMs - The timeoutMs to set.


Copyright © 2004 Mortbay Consulting Pty. Ltd. All Rights Reserved.