org.littleshoot.proxy
Class HttpRequestHandler
java.lang.Object
org.jboss.netty.channel.SimpleChannelUpstreamHandler
org.littleshoot.proxy.HttpRequestHandler
- All Implemented Interfaces:
- org.jboss.netty.channel.ChannelHandler, org.jboss.netty.channel.ChannelUpstreamHandler, ConnectionData, RelayListener
public class HttpRequestHandler
- extends org.jboss.netty.channel.SimpleChannelUpstreamHandler
- implements RelayListener, ConnectionData
Class for handling all HTTP requests from the browser to the proxy.
Note this class only ever handles a single connection from the browser.
The browser can and will, however, send requests to multiple hosts using
that same connection, i.e. it will send a request to host B once a request
to host A has completed.
| Nested classes/interfaces inherited from interface org.jboss.netty.channel.ChannelHandler |
org.jboss.netty.channel.ChannelHandler.Sharable |
|
Constructor Summary |
HttpRequestHandler(ProxyCacheManager cacheManager,
ProxyAuthorizationManager authorizationManager,
org.jboss.netty.channel.group.ChannelGroup channelGroup,
ChainProxyManager chainProxyManager,
RelayPipelineFactoryFactory relayPipelineFactoryFactory,
org.jboss.netty.channel.socket.ClientSocketChannelFactory clientChannelFactory)
Creates a new class for handling HTTP requests with the specified
authentication manager. |
HttpRequestHandler(ProxyCacheManager cacheManager,
ProxyAuthorizationManager authorizationManager,
org.jboss.netty.channel.group.ChannelGroup channelGroup,
RelayPipelineFactoryFactory relayPipelineFactoryFactory,
org.jboss.netty.channel.socket.ClientSocketChannelFactory clientChannelFactory)
Creates a new class for handling HTTP requests with the specified
authentication manager. |
HttpRequestHandler(RelayPipelineFactoryFactory relayPipelineFactoryFactory,
org.jboss.netty.channel.socket.ClientSocketChannelFactory clientChannelFactory)
Creates a new class for handling HTTP requests with no frills. |
|
Method Summary |
void |
addInterestOpsListener(InterestOpsListener opsListener)
|
void |
channelClosed(org.jboss.netty.channel.ChannelHandlerContext ctx,
org.jboss.netty.channel.ChannelStateEvent cse)
|
void |
channelInterestChanged(org.jboss.netty.channel.ChannelHandlerContext ctx,
org.jboss.netty.channel.ChannelStateEvent cse)
|
void |
channelOpen(org.jboss.netty.channel.ChannelHandlerContext ctx,
org.jboss.netty.channel.ChannelStateEvent cse)
|
protected void |
cleanupJmx()
|
void |
exceptionCaught(org.jboss.netty.channel.ChannelHandlerContext ctx,
org.jboss.netty.channel.ExceptionEvent e)
|
String |
getAnsweredReqeusts()
|
int |
getClientConnections()
|
int |
getOutgoingConnections()
|
int |
getRequestsSent()
|
int |
getResponsesReceived()
|
int |
getTotalClientConnections()
|
Set<org.jboss.netty.handler.codec.http.HttpRequest> |
getUnansweredHttpRequests()
|
String |
getUnansweredRequests()
|
void |
messageReceived(org.jboss.netty.channel.ChannelHandlerContext ctx,
org.jboss.netty.channel.MessageEvent me)
|
void |
onChannelAvailable(String hostAndPortKey,
org.jboss.netty.channel.ChannelFuture cf)
|
void |
onRelayChannelClose(org.jboss.netty.channel.Channel browserToProxyChannel,
String key,
int unansweredRequestsOnChannel,
boolean closedEndsResponseBody)
This is called when a relay channel to a remote server is closed in order
for this class to perform any necessary cleanup. |
void |
onRelayHttpResponse(org.jboss.netty.channel.Channel browserToProxyChannel,
String key,
org.jboss.netty.handler.codec.http.HttpRequest httpRequest)
|
| Methods inherited from class org.jboss.netty.channel.SimpleChannelUpstreamHandler |
channelBound, channelConnected, channelDisconnected, channelUnbound, childChannelClosed, childChannelOpen, handleUpstream, writeComplete |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
HttpRequestHandler
public HttpRequestHandler(RelayPipelineFactoryFactory relayPipelineFactoryFactory,
org.jboss.netty.channel.socket.ClientSocketChannelFactory clientChannelFactory)
- Creates a new class for handling HTTP requests with no frills.
- Parameters:
relayPipelineFactoryFactory - The factory for creating factories
for channels to relay data from external sites back to clients.clientChannelFactory - The factory for creating outgoing channels
to external sites.
HttpRequestHandler
public HttpRequestHandler(ProxyCacheManager cacheManager,
ProxyAuthorizationManager authorizationManager,
org.jboss.netty.channel.group.ChannelGroup channelGroup,
RelayPipelineFactoryFactory relayPipelineFactoryFactory,
org.jboss.netty.channel.socket.ClientSocketChannelFactory clientChannelFactory)
- Creates a new class for handling HTTP requests with the specified
authentication manager.
- Parameters:
cacheManager - The manager for the cache.authorizationManager - The class that handles any
proxy authentication requirements.channelGroup - The group of channels for keeping track of all
channels we've opened.relayPipelineFactoryFactory - The factory for creating factories
for channels to relay data from external sites back to clients.clientChannelFactory - The factory for creating outgoing channels
to external sites.
HttpRequestHandler
public HttpRequestHandler(ProxyCacheManager cacheManager,
ProxyAuthorizationManager authorizationManager,
org.jboss.netty.channel.group.ChannelGroup channelGroup,
ChainProxyManager chainProxyManager,
RelayPipelineFactoryFactory relayPipelineFactoryFactory,
org.jboss.netty.channel.socket.ClientSocketChannelFactory clientChannelFactory)
- Creates a new class for handling HTTP requests with the specified
authentication manager.
- Parameters:
cacheManager - The manager for the cache.authorizationManager - The class that handles any
proxy authentication requirements.channelGroup - The group of channels for keeping track of all
channels we've opened.chainProxyManager - upstream proxy server host and port or null
if none used.relayPipelineFactoryFactory - The relay pipeline factory.clientChannelFactory - The factory for creating outgoing channels
to external sites.
cleanupJmx
protected void cleanupJmx()
messageReceived
public void messageReceived(org.jboss.netty.channel.ChannelHandlerContext ctx,
org.jboss.netty.channel.MessageEvent me)
- Overrides:
messageReceived in class org.jboss.netty.channel.SimpleChannelUpstreamHandler
onChannelAvailable
public void onChannelAvailable(String hostAndPortKey,
org.jboss.netty.channel.ChannelFuture cf)
- Specified by:
onChannelAvailable in interface RelayListener
channelInterestChanged
public void channelInterestChanged(org.jboss.netty.channel.ChannelHandlerContext ctx,
org.jboss.netty.channel.ChannelStateEvent cse)
throws Exception
- Overrides:
channelInterestChanged in class org.jboss.netty.channel.SimpleChannelUpstreamHandler
- Throws:
Exception
channelOpen
public void channelOpen(org.jboss.netty.channel.ChannelHandlerContext ctx,
org.jboss.netty.channel.ChannelStateEvent cse)
throws Exception
- Overrides:
channelOpen in class org.jboss.netty.channel.SimpleChannelUpstreamHandler
- Throws:
Exception
channelClosed
public void channelClosed(org.jboss.netty.channel.ChannelHandlerContext ctx,
org.jboss.netty.channel.ChannelStateEvent cse)
- Overrides:
channelClosed in class org.jboss.netty.channel.SimpleChannelUpstreamHandler
onRelayChannelClose
public void onRelayChannelClose(org.jboss.netty.channel.Channel browserToProxyChannel,
String key,
int unansweredRequestsOnChannel,
boolean closedEndsResponseBody)
- This is called when a relay channel to a remote server is closed in order
for this class to perform any necessary cleanup. Note that this is
called on the same thread as the incoming request processing.
- Specified by:
onRelayChannelClose in interface RelayListener
onRelayHttpResponse
public void onRelayHttpResponse(org.jboss.netty.channel.Channel browserToProxyChannel,
String key,
org.jboss.netty.handler.codec.http.HttpRequest httpRequest)
- Specified by:
onRelayHttpResponse in interface RelayListener
exceptionCaught
public void exceptionCaught(org.jboss.netty.channel.ChannelHandlerContext ctx,
org.jboss.netty.channel.ExceptionEvent e)
throws Exception
- Overrides:
exceptionCaught in class org.jboss.netty.channel.SimpleChannelUpstreamHandler
- Throws:
Exception
getClientConnections
public int getClientConnections()
- Specified by:
getClientConnections in interface ConnectionData
getTotalClientConnections
public int getTotalClientConnections()
- Specified by:
getTotalClientConnections in interface ConnectionData
getOutgoingConnections
public int getOutgoingConnections()
- Specified by:
getOutgoingConnections in interface ConnectionData
getRequestsSent
public int getRequestsSent()
- Specified by:
getRequestsSent in interface ConnectionData
getResponsesReceived
public int getResponsesReceived()
- Specified by:
getResponsesReceived in interface ConnectionData
getUnansweredRequests
public String getUnansweredRequests()
- Specified by:
getUnansweredRequests in interface ConnectionData
getUnansweredHttpRequests
public Set<org.jboss.netty.handler.codec.http.HttpRequest> getUnansweredHttpRequests()
getAnsweredReqeusts
public String getAnsweredReqeusts()
- Specified by:
getAnsweredReqeusts in interface ConnectionData
addInterestOpsListener
public void addInterestOpsListener(InterestOpsListener opsListener)
- Specified by:
addInterestOpsListener in interface RelayListener
Copyright © 2009-2013 LittleShoot. All Rights Reserved.