abdera-commits mailing list archives

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

URL: http://svn.apache.org/viewvc?rev=429436&view=rev
Log:
Only use the local cache for methods that do not lead to a change in server state (specifically,
GET, HEAD and OPTIONS).

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

Modified: incubator/abdera/java/trunk/client/src/main/java/org/apache/abdera/protocol/client/CommonsClient.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/client/src/main/java/org/apache/abdera/protocol/client/CommonsClient.java?rev=429436&r1=429435&r2=429436&view=diff
==============================================================================
--- incubator/abdera/java/trunk/client/src/main/java/org/apache/abdera/protocol/client/CommonsClient.java
(original)
+++ incubator/abdera/java/trunk/client/src/main/java/org/apache/abdera/protocol/client/CommonsClient.java
Mon Aug  7 12:12:28 2006
@@ -60,6 +60,16 @@
       HttpClientParams.USE_EXPECT_CONTINUE, true);    
   }
   
+  /**
+   * We're only going to cache GET, HEAD and OPTIONS requests.
+   * State modifying requests will be passed on through to the server
+   */
+  private boolean isPassthroughMethod(String method) {
+    return (!method.equals("GET") &&
+            !method.equals("HEAD") &&
+            !method.equals("OPTIONS"));
+  }
+  
   @Override
   public Response execute(
     String method, 
@@ -72,7 +82,8 @@
         CachedResponse cached_response = null;
         Cache cache = getCache();
         CacheDisposition disp = CacheDisposition.TRANSPARENT;
-        if (cache != null && 
+        if (!isPassthroughMethod(method) &&
+            cache != null && 
             options.getNoCache() == false && 
             options.getNoStore() == false &&
             options.getUseLocalCache()) {



Mime
View raw message