View Javadoc
1   package org.littleshoot.proxy;
2   
3   import java.util.concurrent.Future;
4   
5   import org.jboss.netty.buffer.ChannelBuffer;
6   import org.jboss.netty.channel.Channel;
7   import org.jboss.netty.handler.codec.http.HttpRequest;
8   import org.jboss.netty.handler.codec.http.HttpResponse;
9   
10  /***
11   * Interface for classes that handle caching on the proxy.
12   */
13  public interface ProxyCacheManager {
14  
15      /***
16       * Writes a cached response back to the browser if we have a hit in the
17       * cache.
18       * 
19       * @param request The HTTP request.
20       * @param channel The channel the request came in on.
21       * @return <code>true</code> if there was a hit in the cache and we
22       * returned a response, otherwise <code>false</code>.
23       */
24      boolean returnCacheHit(HttpRequest request, Channel channel);
25  
26      /***
27       * Caches the request and response object, if appropriate.
28       * 
29       * @param originalRequest The original HTTP request.
30       * @param httpResponse The HTTP response.
31       * @param response The response object. Can be an HttpResponse or an
32       * HttpChunk.
33       * @param encoded The encoded response to cache.
34       * @return The future for when the cache operation is executed.
35       */
36      Future<String> cache(HttpRequest originalRequest, HttpResponse httpResponse,
37          Object response, ChannelBuffer encoded);
38  
39  }