org.mortbay.http

Class 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()
Constructor.
HttpTunnel(Socket socket, InputStream in, OutputStream out)
Constructor.

Method Summary

static int
copyBytes(InputStream in, OutputStream out, long byteCount)
Copy Stream in to Stream for byteCount bytes or until EOF or exception.
Socket
getSocket()
int
getTimeoutMs()
void
handle(InputStream in, OutputStream out)
handle method.
void
setTimeoutMs(int timeoutMs)

Constructor Details

HttpTunnel

protected HttpTunnel()
Constructor.

HttpTunnel

public HttpTunnel(Socket socket,
                  InputStream in,
                  OutputStream out)
            throws 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

Method Details

copyBytes

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

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.