org.littleshoot.proxy
Class HttpRequestHandler

java.lang.Object
  extended by org.jboss.netty.channel.SimpleChannelUpstreamHandler
      extended by 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 Class Summary
 
Nested classes/interfaces inherited from interface org.jboss.netty.channel.ChannelHandler
org.jboss.netty.channel.ChannelHandler.Sharable
 
Constructor Summary
HttpRequestHandler(org.jboss.netty.channel.socket.ClientSocketChannelFactory clientChannelFactory, RelayPipelineFactoryFactory relayPipelineFactoryFactory)
          Creates a new class for handling HTTP requests with no frills.
HttpRequestHandler(ProxyCacheManager cacheManager, ProxyAuthorizationManager authorizationManager, org.jboss.netty.channel.group.ChannelGroup channelGroup, org.jboss.netty.channel.socket.ClientSocketChannelFactory clientChannelFactory, RelayPipelineFactoryFactory relayPipelineFactoryFactory)
          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, org.jboss.netty.channel.socket.ClientSocketChannelFactory clientChannelFactory, String chainProxyHostAndPort, RelayPipelineFactoryFactory relayPipelineFactoryFactory, boolean useJmx)
          Creates a new class for handling HTTP requests with the specified authentication manager.
 
Method Summary
 void channelClosed(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)
           
 void exceptionCaught(org.jboss.netty.channel.ChannelHandlerContext ctx, org.jboss.netty.channel.ExceptionEvent e)
           
 String getAnsweredReqeusts()
           
 int getClientConnections()
           
 int getOutgoingConnections()
           
 String getRequests()
           
 int getRequestsSent()
           
 int getResponsesReceived()
           
 int getTotalClientConnections()
           
 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)
           
 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, channelInterestChanged, channelUnbound, childChannelClosed, childChannelOpen, handleUpstream, writeComplete
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

HttpRequestHandler

public HttpRequestHandler(org.jboss.netty.channel.socket.ClientSocketChannelFactory clientChannelFactory,
                          RelayPipelineFactoryFactory relayPipelineFactoryFactory)
Creates a new class for handling HTTP requests with no frills.

Parameters:
clientChannelFactory - The common channel factory for clients.

HttpRequestHandler

public HttpRequestHandler(ProxyCacheManager cacheManager,
                          ProxyAuthorizationManager authorizationManager,
                          org.jboss.netty.channel.group.ChannelGroup channelGroup,
                          org.jboss.netty.channel.socket.ClientSocketChannelFactory clientChannelFactory,
                          RelayPipelineFactoryFactory relayPipelineFactoryFactory)
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.
filters - HTTP filtering rules.
clientChannelFactory - The common channel factory for clients.

HttpRequestHandler

public HttpRequestHandler(ProxyCacheManager cacheManager,
                          ProxyAuthorizationManager authorizationManager,
                          org.jboss.netty.channel.group.ChannelGroup channelGroup,
                          org.jboss.netty.channel.socket.ClientSocketChannelFactory clientChannelFactory,
                          String chainProxyHostAndPort,
                          RelayPipelineFactoryFactory relayPipelineFactoryFactory,
                          boolean useJmx)
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.
filters - HTTP filtering rules.
clientChannelFactory - The common channel factory for clients.
chainProxyHostAndPort - upstream proxy server host and port or null if none used.
requestFilter - An optional filter for HTTP requests.
useJmx - Whether or not to expose debugging properties via JMX.
Method Detail

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

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)
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

getAnsweredReqeusts

public String getAnsweredReqeusts()
Specified by:
getAnsweredReqeusts in interface ConnectionData

getRequests

public String getRequests()
Specified by:
getRequests in interface ConnectionData


Copyright © 2009-2011 LittleShoot. All Rights Reserved.