public class ConnectHandler extends HandlerWrapper
Implementation of a Handler that supports HTTP CONNECT.
| Modifier and Type | Class and Description |
|---|---|
protected static class |
ConnectHandler.ConnectContext |
protected class |
ConnectHandler.ConnectManager |
class |
ConnectHandler.DownstreamConnection |
class |
ConnectHandler.UpstreamConnection |
AbstractHandler.ErrorDispatchHandlerAbstractLifeCycle.AbstractLifeCycleListenerLifeCycle.ListenerContainer.InheritedListener, Container.Listener| Modifier and Type | Field and Description |
|---|---|
protected static Logger |
LOG |
_handler| Constructor and Description |
|---|
ConnectHandler() |
ConnectHandler(Handler handler) |
| Modifier and Type | Method and Description |
|---|---|
protected void |
connectToServer(HttpServletRequest request,
String host,
int port,
Promise<SocketChannel> promise) |
protected void |
doStart() |
void |
dump(Appendable out,
String indent) |
Set<String> |
getBlackListHosts() |
int |
getBufferSize() |
ByteBufferPool |
getByteBufferPool() |
long |
getConnectTimeout() |
Executor |
getExecutor() |
long |
getIdleTimeout() |
Scheduler |
getScheduler() |
Set<String> |
getWhiteListHosts() |
void |
handle(String target,
Request baseRequest,
HttpServletRequest request,
HttpServletResponse response) |
protected boolean |
handleAuthentication(HttpServletRequest request,
HttpServletResponse response,
String address)
Handles the authentication before setting up the tunnel to the remote server.
|
protected void |
handleConnect(Request baseRequest,
HttpServletRequest request,
HttpServletResponse response,
String serverAddress)
Handles a CONNECT request.
|
protected InetSocketAddress |
newConnectAddress(String host,
int port)
Creates the server address to connect to.
|
protected ConnectHandler.DownstreamConnection |
newDownstreamConnection(EndPoint endPoint,
ConcurrentMap<String,Object> context) |
protected SelectorManager |
newSelectorManager() |
protected ConnectHandler.UpstreamConnection |
newUpstreamConnection(EndPoint endPoint,
ConnectHandler.ConnectContext connectContext) |
protected void |
onConnectFailure(HttpServletRequest request,
HttpServletResponse response,
AsyncContext asyncContext,
Throwable failure) |
protected void |
onConnectSuccess(ConnectHandler.ConnectContext connectContext,
ConnectHandler.UpstreamConnection upstreamConnection) |
protected void |
prepareContext(HttpServletRequest request,
ConcurrentMap<String,Object> context) |
protected int |
read(EndPoint endPoint,
ByteBuffer buffer,
ConcurrentMap<String,Object> context)
Reads (with non-blocking semantic) into the given
buffer from the given endPoint. |
void |
setBufferSize(int bufferSize) |
void |
setByteBufferPool(ByteBufferPool bufferPool) |
void |
setConnectTimeout(long connectTimeout) |
void |
setExecutor(Executor executor) |
void |
setIdleTimeout(long idleTimeout) |
void |
setScheduler(Scheduler scheduler) |
boolean |
validateDestination(String host,
int port)
Checks the given
host and port against whitelist and blacklist. |
protected void |
write(EndPoint endPoint,
ByteBuffer buffer,
Callback callback,
ConcurrentMap<String,Object> context)
Writes (with non-blocking semantic) the given buffer of data onto the given endPoint.
|
destroy, expandChildren, getHandler, getHandlers, insertHandler, setHandlerexpandHandler, findContainerOf, getChildHandlerByClass, getChildHandlers, getChildHandlersByClass, setServerdoError, doStop, dumpThis, getServeraddBean, addBean, addBean, addEventListener, addManaged, contains, dump, dump, dump, dump, dumpBeans, dumpObject, dumpStdErr, getBean, getBeans, getBeans, isManaged, manage, removeBean, removeBeans, removeEventListener, setBeans, setStopTimeout, start, stop, unmanage, updateBean, updateBean, updateBeansaddLifeCycleListener, getState, getState, getStopTimeout, isFailed, isRunning, isStarted, isStarting, isStopped, isStopping, removeLifeCycleListener, start, stopclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitaddLifeCycleListener, isFailed, isRunning, isStarted, isStarting, isStopped, isStopping, removeLifeCycleListener, start, stopprotected static final Logger LOG
public ConnectHandler()
public ConnectHandler(Handler handler)
public Executor getExecutor()
public void setExecutor(Executor executor)
public Scheduler getScheduler()
public void setScheduler(Scheduler scheduler)
public ByteBufferPool getByteBufferPool()
public void setByteBufferPool(ByteBufferPool bufferPool)
public long getConnectTimeout()
public void setConnectTimeout(long connectTimeout)
connectTimeout - the timeout, in milliseconds, to connect to the remote serverpublic long getIdleTimeout()
public void setIdleTimeout(long idleTimeout)
idleTimeout - the idle timeout, in millisecondspublic int getBufferSize()
public void setBufferSize(int bufferSize)
protected void doStart()
throws Exception
doStart in class AbstractHandlerExceptionprotected SelectorManager newSelectorManager()
public void handle(String target, Request baseRequest, HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
handle in interface Handlerhandle in class HandlerWrapperServletExceptionIOExceptionprotected void handleConnect(Request baseRequest, HttpServletRequest request, HttpServletResponse response, String serverAddress)
Handles a CONNECT request.
CONNECT requests may have authentication headers such as Proxy-Authorization
that authenticate the client with the proxy.
baseRequest - Jetty-specific http requestrequest - the http requestresponse - the http responseserverAddress - the remote server address in the form host:portprotected void connectToServer(HttpServletRequest request, String host, int port, Promise<SocketChannel> promise)
protected InetSocketAddress newConnectAddress(String host, int port)
host - The host from the CONNECT requestport - The port from the CONNECT requestprotected void onConnectSuccess(ConnectHandler.ConnectContext connectContext, ConnectHandler.UpstreamConnection upstreamConnection)
protected void onConnectFailure(HttpServletRequest request, HttpServletResponse response, AsyncContext asyncContext, Throwable failure)
protected boolean handleAuthentication(HttpServletRequest request, HttpServletResponse response, String address)
Handles the authentication before setting up the tunnel to the remote server.
The default implementation returns true.
request - the HTTP requestresponse - the HTTP responseaddress - the address of the remote server in the form host:port.protected ConnectHandler.DownstreamConnection newDownstreamConnection(EndPoint endPoint, ConcurrentMap<String,Object> context)
protected ConnectHandler.UpstreamConnection newUpstreamConnection(EndPoint endPoint, ConnectHandler.ConnectContext connectContext)
protected void prepareContext(HttpServletRequest request, ConcurrentMap<String,Object> context)
protected int read(EndPoint endPoint, ByteBuffer buffer, ConcurrentMap<String,Object> context) throws IOException
Reads (with non-blocking semantic) into the given buffer from the given endPoint.
endPoint - the endPoint to read frombuffer - the buffer to read data intocontext - the context information related to the connectionIOException - if the endPoint cannot be readprotected void write(EndPoint endPoint, ByteBuffer buffer, Callback callback, ConcurrentMap<String,Object> context)
Writes (with non-blocking semantic) the given buffer of data onto the given endPoint.
endPoint - the endPoint to write tobuffer - the buffer to writecallback - the completion callback to invokecontext - the context information related to the connectionpublic boolean validateDestination(String host, int port)
host and port against whitelist and blacklist.host - the host to checkport - the port to checkpublic void dump(Appendable out, String indent) throws IOException
dump in interface Dumpabledump in class ContainerLifeCycleIOExceptionCopyright © 1995–2017 Webtide. All rights reserved.