So, basically, this chunk of code from DefaultRelayPipelineFactory: filter = filters.get(hostAndPort); if (filter == null) { LOG.info(“Filter not found in: {}”, filters); shouldFilter = false; } else { LOG.debug(“Using filter: {}”, filter); shouldFilter = filter.shouldFilterResponses(httpRequest); // We decompress and aggregate chunks for responses from // sites we’re applying rules to. if (shouldFilter) { pipeline.addLast(“inflater”, new HttpContentDecompressor()); pipeline.addLast(“aggregator”, new HttpChunkAggregator(filter.getMaxResponseSize()));//2048576)); } } LOG.debug(“Filtering: “+shouldFilter);
Needs to get moved into HttpRequestHandler whenever a new host and port combination come in over the connection, ideally along with the “filter off” state. So it’s not a huge change really.
- constructor takes a pile of info about the pipeline
- getPipeline constructs the actual pipeline that will get used.
- filters based on hostAndPort (to determine the filter class), and then filters based on shouldFilterResponses(httpRequest) to determine specific requests.
- needs to be moved into HttpRequestHandler?
- pipeline contents:
- addLast(“decoder”, new HttpResponseDecoder)
- addLast(“inflater”, new HttpContentDecompressor)
- addLast(“aggregator”, new HttpChunkAggregator)
- handler = HttpRelayingHandler(browserToProxyChannel, channelGroup, filter, relayListener, hostAndPort)
- addLast(“encoder”, new ProxyHttpRequestEncoder(handler, requestFilter, chainProxyHostAndPort)
- addLast(“idle”, new IdleStateHandler)
- addLast(“idleAware”, new IdleAwareHandler)
- addLast(“handler”, handler) from above, HttpRelayingHandler
- Why does the handler get injected into the pipeline twice? (Once in the ProxyHttpRequestEncoder(HttpRelayingHandler), once at the very end)
- PHRE gets this.relayingHandler = handler
- this.relayingHandler is fed the request through the requestEncoded() method
- That is all that PHRE does with the handler
- Pass the filter list into the HttpRelayingHandler instead of passing the filter in, from DefaultRelayPipelineFactory
162849 2011-10-04 16:02:07,497 DEBUG [New I/O client worker #1-4] jsproxy1.ChattyNullFilter.shouldFilterResponses (ChattyNullFilter.java:26) - Request for: http://www.reddit.com/ 162913 2011-10-04 16:02:07,561 DEBUG [New I/O client worker #1-4] jsproxy1.ChattyNullFilter.shouldFilterResponses (ChattyNullFilter.java:26) - Request for: http://www.reddit.com/static/reddit.y7COJQdypiM.css 162921 2011-10-04 16:02:07,569 DEBUG [New I/O client worker #1-1] jsproxy1.ChattyNullFilter.shouldFilterResponses (ChattyNullFilter.java:26) - Request for: http://www.reddit.com/static/reddit.en.VCS0mf7z7TA.js 163613 2011-10-04 16:02:08,261 DEBUG [New I/O client worker #1-4] jsproxy1.ChattyNullFilter.shouldFilterResponses (ChattyNullFilter.java:26) - Request for: http://www.reddit.com/static/sprite-main.png?v=816b8dcd1f863d0343bb5e0d9e094215 163632 2011-10-04 16:02:08,280 DEBUG [New I/O client worker #1-1] jsproxy1.ChattyNullFilter.shouldFilterResponses (ChattyNullFilter.java:26) - Request for: http://www.reddit.com/static/bg-button-negative-pressed.png 163690 2011-10-04 16:02:08,338 DEBUG [New I/O client worker #1-3] jsproxy1.ChattyNullFilter.shouldFilterResponses (ChattyNullFilter.java:26) - Request for: http://www.reddit.com/static/bg-button-positive-unpressed.png 163727 2011-10-04 16:02:08,375 DEBUG [New I/O client worker #1-3] jsproxy1.ChattyNullFilter.shouldFilterResponses (ChattyNullFilter.java:26) - Request for: http://www.reddit.com/static/bg-button-positive-pressed.png 163782 2011-10-04 16:02:08,430 DEBUG [New I/O client worker #1-4] jsproxy1.ChattyNullFilter.shouldFilterResponses (ChattyNullFilter.java:26) - Request for: http://www.reddit.com/static/bg-button-negative-unpressed.png 163810 2011-10-04 16:02:08,458 DEBUG [New I/O client worker #1-3] jsproxy1.ChattyNullFilter.shouldFilterResponses (ChattyNullFilter.java:26) - Request for: http://www.reddit.com/static/kill.png 163819 2011-10-04 16:02:08,467 DEBUG [New I/O client worker #1-1] jsproxy1.ChattyNullFilter.shouldFilterResponses (ChattyNullFilter.java:26) - Request for: http://www.reddit.com/static/pixel.png 164078 2011-10-04 16:02:08,726 DEBUG [New I/O client worker #1-1] jsproxy1.ChattyNullFilter.shouldFilterResponses (ChattyNullFilter.java:26) - Request for: http://www.reddit.com/static/goldmorelink.png 164083 2011-10-04 16:02:08,731 DEBUG [New I/O client worker #1-4] jsproxy1.ChattyNullFilter.shouldFilterResponses (ChattyNullFilter.java:26) - Request for: http://www.reddit.com/api/onload
- 12 calls to www.reddit.com
- proxy reports 12 calls too!