abdera-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jmsn...@apache.org
Subject svn commit: r429437 - /incubator/abdera/java/trunk/client/src/main/java/org/apache/abdera/protocol/cache/InMemoryCachedResponse.java
Date Mon, 07 Aug 2006 19:12:46 GMT
Author: jmsnell
Date: Mon Aug  7 12:12:45 2006
New Revision: 429437

URL: http://svn.apache.org/viewvc?rev=429437&view=rev
Log:
Filter out hop-by-hop headers from the cached response

Modified:
    incubator/abdera/java/trunk/client/src/main/java/org/apache/abdera/protocol/cache/InMemoryCachedResponse.java

Modified: incubator/abdera/java/trunk/client/src/main/java/org/apache/abdera/protocol/cache/InMemoryCachedResponse.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/client/src/main/java/org/apache/abdera/protocol/cache/InMemoryCachedResponse.java?rev=429437&r1=429436&r2=429437&view=diff
==============================================================================
--- incubator/abdera/java/trunk/client/src/main/java/org/apache/abdera/protocol/cache/InMemoryCachedResponse.java
(original)
+++ incubator/abdera/java/trunk/client/src/main/java/org/apache/abdera/protocol/cache/InMemoryCachedResponse.java
Mon Aug  7 12:12:45 2006
@@ -49,7 +49,8 @@
     this.uri = response.getUri();
     String[] headers = response.getHeaderNames();
     for (String header : headers) {
-      if (!isNoCacheOrPrivate(header, response)) {
+      if (!isNoCacheOrPrivate(header, response) &&
+          !isHopByHop(header)) {
         String[] values = response.getHeaders(header);
         List<String> list = Arrays.asList(values);
         getHeaders().put(header, list);
@@ -61,6 +62,23 @@
     response.setInputStream(getInputStream());
   }
 
+  /**
+   * We don't cache hop-by-hop headers
+   * TODO: There may actually be other hop-by-hop headers we need to filter 
+   *       out.  They'll be listed in the Connection header. see Section 14.10
+   *       of RFC2616 (last paragraph)
+   */
+  private boolean isHopByHop(String header) {
+    return (header.equalsIgnoreCase("Connection") ||
+            header.equalsIgnoreCase("Keep-Alive") ||
+            header.equalsIgnoreCase("Proxy-Authenticate") ||
+            header.equalsIgnoreCase("Proxy-Authorization") ||
+            header.equalsIgnoreCase("TE") ||
+            header.equalsIgnoreCase("Trailers") ||
+            header.equalsIgnoreCase("Transfer-Encoding") ||
+            header.equalsIgnoreCase("Upgrade"));
+  }
+  
   /**
    * This is terribly inefficient, but it is an in-memory cache
    * that is being used by parsers that incrementally consume 



Mime
View raw message