Top Description Inners Fields Constructors Methods
org.eclipse.jetty.server.handler

public Class ConnectHandler

extends Wrapper
Class Inheritance
Imports
java.io.Closeable, .IOException, java.net.InetSocketAddress, java.nio.ByteBuffer, java.nio.channels.SelectableChannel, .SelectionKey, .SocketChannel, java.util.HashSet, .Set, java.util.concurrent.ConcurrentHashMap, .ConcurrentMap, .Executor, org.eclipse.jetty.http.HttpFields, .HttpHeader, .HttpHeaderValue, .HttpMethod, .HttpStatus, .HttpURI, org.eclipse.jetty.io.AbstractConnection, .ByteBufferPool, .Connection, .EndPoint, .ManagedSelector, .RetainableByteBuffer, .SelectorManager, .SocketChannelEndPoint, org.eclipse.jetty.server.Handler, .HttpStream, .Request, .Response, .TunnelSupport, org.eclipse.jetty.util.Callback, .HostPort, .IteratingCallback, .Promise, org.eclipse.jetty.util.thread.Scheduler, org.slf4j.Logger, .LoggerFactory

Implementation of a Handler that supports HTTP CONNECT.

Nested and Inner Type Summary

Modifier and TypeClass and Description
protected static class
protected class
public class
private abstract static class
public class

Field Summary

Modifier and TypeField and Description
private final Set<String>
private ByteBufferPool
private int
private long
private Executor
private long
private static final Logger
private Scheduler
private SelectorManager
private final Set<String>

Constructor Summary

AccessConstructor and Description
public
public

Method Summary

Modifier and TypeMethod and Description
private void
close(Closeable closeable)

protected void
connectToServer(Request request, String host, int port, Promise<SocketChannel> promise)

protected void
doStart()

Overrides org.eclipse.jetty.server.Handler.Abstract.doStart.

Starts the managed lifecycle beans in the order they were added.
public Set<String>
public int
public ByteBufferPool
public long

Returns:

the timeout, in milliseconds, to connect to the remote server
getConnectTimeout
()

Get the timeout, in milliseconds, to connect to the remote server.

public Executor
public long

Returns:

the idle timeout, in milliseconds
getIdleTimeout
()

Get the idle timeout, in milliseconds.

public Scheduler
public Set<String>
public boolean
handle(Request
the HTTP request to handle
request
,
Response
the HTTP response to handle
response
,
Callback
the callback to complete when the handling is complete
callback
)

Overrides org.eclipse.jetty.server.Handler.Wrapper.handle.

Implements org.eclipse.jetty.server.Request.Handler.handle.

Invoked to handle the passed HTTP request and response.

protected boolean

Returns:

true to allow to connect to the remote host, false otherwise
handleAuthentication
(Request
the HTTP request
request
,
Response
the HTTP response
response
,
String
the address of the remote server in the form host:port.
address
)

Handles the authentication before setting up the tunnel to the remote server.

protected void
handleConnect(Request
the jetty request
request
,
Response
the jetty response
response
,
Callback
the callback with which to generate a response
callback
,
String
the remote server address in the form host:port
serverAddress
)

Handles a CONNECT request.

protected InetSocketAddress

Returns:

The InetSocketAddress to connect to.
newConnectAddress
(String
The host from the CONNECT request
host
,
int
The port from the CONNECT request
port
)

Creates the server address to connect to.

protected ConnectHandler.DownstreamConnection
protected SelectorManager
protected ConnectHandler.UpstreamConnection
protected void
onConnectFailure(Request request, Response response, Callback callback, Throwable failure)

protected void
protected void
protected int

Returns:

the number of bytes read (possibly 0 since the read is non-blocking) or -1 if the channel has been closed remotely
read
(EndPoint
the endPoint to read from
endPoint
,
ByteBuffer
the buffer to read data into
buffer
,
ConcurrentMap<String, Object>
the context information related to the connection
context
)

Reads (with non-blocking semantic) into the given buffer from the given endPoint.

private void
sendConnectResponse(Request request, Response response, Callback callback, int statusCode)

public void
setBufferSize(int bufferSize)

public void
public void
setConnectTimeout(long
the timeout, in milliseconds, to connect to the remote server
connectTimeout
)

Set the timeout, in milliseconds, to connect to the remote server.

public void
public void
setIdleTimeout(long
the idle timeout, in milliseconds
idleTimeout
)

Set the idle timeout, in milliseconds.

public void
private void
upgradeConnection(Request request, Connection connection)

public boolean

Returns:

true if it is allowed to connect to the given host and port
validateDestination
(String
the host to check
host
,
int
the port to check
port
)

Checks the given host and port against whitelist and blacklist.

protected void
write(EndPoint
the endPoint to write to
endPoint
,
ByteBuffer
the buffer to write
buffer
,
Callback
the completion callback to invoke
callback
,
ConcurrentMap<String, Object>
the context information related to the connection
context
)

Writes (with non-blocking semantic) the given buffer of data onto the given endPoint.

Inherited from org.eclipse.jetty.server.Handler.Wrapper:
getHandlergetInvocationTypesetHandler