org.mortbay.http

Class HttpTunnel

public class HttpTunnel extends 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
protected HttpTunnel()
Constructor.
HttpTunnel(Socket socket, InputStream in, OutputStream out)
Constructor.
Method Summary
static intcopyBytes(InputStream in, OutputStream out, long byteCount)
Copy Stream in to Stream for byteCount bytes or until EOF or exception.
SocketgetSocket()
intgetTimeoutMs()
voidhandle(InputStream in, OutputStream out)
handle method.
voidsetTimeoutMs(int timeoutMs)

Constructor Detail

HttpTunnel

protected HttpTunnel()
Constructor.

HttpTunnel

public HttpTunnel(Socket socket, InputStream in, OutputStream out)
Constructor.

Parameters: socket The tunnel socket. timeoutMs The maximum time to wait for a read on the tunnel. Note that sotimer exceptions are ignored by the tunnel. in Alternative input stream or null if using normal socket stream out Alternative output stream or null if using normal socket stream timeoutMs

Throws: IOException

Method Detail

copyBytes

public static int copyBytes(InputStream in, OutputStream out, long byteCount)
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

getSocket

public Socket getSocket()

Returns: Returns the socket.

getTimeoutMs

public int getTimeoutMs()

Returns: Returns the timeoutMs.

handle

public void handle(InputStream in, 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

setTimeoutMs

public void setTimeoutMs(int timeoutMs)

Parameters: timeoutMs The timeoutMs to set.

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