org.littleshoot.proxy
Class HttpRelayingHandler

java.lang.Object
  extended by org.jboss.netty.channel.SimpleChannelUpstreamHandler
      extended by org.littleshoot.proxy.HttpRelayingHandler
All Implemented Interfaces:
org.jboss.netty.channel.ChannelHandler, org.jboss.netty.channel.ChannelUpstreamHandler

public class HttpRelayingHandler
extends org.jboss.netty.channel.SimpleChannelUpstreamHandler

Class that simply relays traffic from a remote server the proxy is connected to back to the browser.


Nested Class Summary
 
Nested classes/interfaces inherited from interface org.jboss.netty.channel.ChannelHandler
org.jboss.netty.channel.ChannelHandler.Sharable
 
Constructor Summary
HttpRelayingHandler(org.jboss.netty.channel.Channel browserToProxyChannel, org.jboss.netty.channel.group.ChannelGroup channelGroup, HttpFilter filter, RelayListener relayListener, String hostAndPort)
          Creates a new HttpRelayingHandler with the specified connection to the browser.
HttpRelayingHandler(org.jboss.netty.channel.Channel browserToProxyChannel, org.jboss.netty.channel.group.ChannelGroup channelGroup, RelayListener relayListener, String hostAndPort)
          Creates a new HttpRelayingHandler with the specified connection to the browser.
 
Method Summary
 void channelClosed(org.jboss.netty.channel.ChannelHandlerContext ctx, org.jboss.netty.channel.ChannelStateEvent e)
           
 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)
           
 void messageReceived(org.jboss.netty.channel.ChannelHandlerContext ctx, org.jboss.netty.channel.MessageEvent me)
           
 void requestEncoded(org.jboss.netty.handler.codec.http.HttpRequest request)
          Adds this HTTP request.
 
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

HttpRelayingHandler

public HttpRelayingHandler(org.jboss.netty.channel.Channel browserToProxyChannel,
                           org.jboss.netty.channel.group.ChannelGroup channelGroup,
                           RelayListener relayListener,
                           String hostAndPort)
Creates a new HttpRelayingHandler with the specified connection to the browser.

Parameters:
browserToProxyChannel - The browser connection.
channelGroup - Keeps track of channels to close on shutdown.
hostAndPort - Host and port we're relaying to.

HttpRelayingHandler

public HttpRelayingHandler(org.jboss.netty.channel.Channel browserToProxyChannel,
                           org.jboss.netty.channel.group.ChannelGroup channelGroup,
                           HttpFilter filter,
                           RelayListener relayListener,
                           String hostAndPort)
Creates a new HttpRelayingHandler with the specified connection to the browser.

Parameters:
browserToProxyChannel - The browser connection.
channelGroup - Keeps track of channels to close on shutdown.
filter - The HTTP filter.
hostAndPort - Host and port we're relaying to.
Method Detail

messageReceived

public void messageReceived(org.jboss.netty.channel.ChannelHandlerContext ctx,
                            org.jboss.netty.channel.MessageEvent me)
                     throws Exception
Overrides:
messageReceived 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 e)
                   throws Exception
Overrides:
channelClosed in class org.jboss.netty.channel.SimpleChannelUpstreamHandler
Throws:
Exception

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

requestEncoded

public void requestEncoded(org.jboss.netty.handler.codec.http.HttpRequest request)
Adds this HTTP request. We need to keep track of all encoded requests because we ultimately need the request data to determine whether or not we can cache responses. It's a queue because we're dealing with HTTP 1.1 persistent connections, and we need to match all requests with responses. NOTE that this is the original, unmodified request in this case without hop-by-hop headers stripped and without HTTP request filters applied. It's the raw request we received from the client connection. See ProxyHttpRequestEncoder.

Parameters:
request - The HTTP request to add.


Copyright © 2009-2012 LittleShoot. All Rights Reserved.