abdera-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jmsn...@apache.org
Subject svn commit: r518042 - in /incubator/abdera/java/trunk/client/src/main/java/org/apache/abdera/protocol/client: CommonsClient.java util/ClientAuthSSLProtocolSocketFactory.java
Date Wed, 14 Mar 2007 07:06:04 GMT
Author: jmsnell
Date: Wed Mar 14 00:06:03 2007
New Revision: 518042

URL: http://svn.apache.org/viewvc?view=rev&rev=518042
Log:
If the response has not been modified, use the cached version if it's available and if the
user will allow it

Modified:
    incubator/abdera/java/trunk/client/src/main/java/org/apache/abdera/protocol/client/CommonsClient.java
    incubator/abdera/java/trunk/client/src/main/java/org/apache/abdera/protocol/client/util/ClientAuthSSLProtocolSocketFactory.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?view=diff&rev=518042&r1=518041&r2=518042
==============================================================================
--- 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
Wed Mar 14 00:06:03 2007
@@ -120,11 +120,12 @@
     String uri, 
     RequestEntity entity,
     RequestOptions options) {
+      boolean usecache = useCache(method,options);
       try {
         if (options == null) options = getDefaultRequestOptions();
         Cache cache = getCache();
         CacheDisposition disp = 
-          (useCache(method,options)) ? 
+          (usecache) ? 
             cache.getDisposition(uri, options) : 
             CacheDisposition.TRANSPARENT;
         CachedResponse cached_response = cache.get(uri, options);
@@ -149,6 +150,10 @@
               MethodHelper.createMethod(
                 method, uri, entity, options);
             client.executeMethod(httpMethod);
+            if (usecache &&
+                (httpMethod.getStatusCode() == 304 || 
+                 httpMethod.getStatusCode() == 412) &&
+                cached_response != null) return cached_response;
             ClientResponse response = new CommonsResponse(abdera,httpMethod);
             return (options.getUseLocalCache()) ?
               response = cache.update(options, response, cached_response) : 

Modified: incubator/abdera/java/trunk/client/src/main/java/org/apache/abdera/protocol/client/util/ClientAuthSSLProtocolSocketFactory.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/client/src/main/java/org/apache/abdera/protocol/client/util/ClientAuthSSLProtocolSocketFactory.java?view=diff&rev=518042&r1=518041&r2=518042
==============================================================================
--- incubator/abdera/java/trunk/client/src/main/java/org/apache/abdera/protocol/client/util/ClientAuthSSLProtocolSocketFactory.java
(original)
+++ incubator/abdera/java/trunk/client/src/main/java/org/apache/abdera/protocol/client/util/ClientAuthSSLProtocolSocketFactory.java
Wed Mar 14 00:06:03 2007
@@ -1,4 +1,22 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one or more
+* contributor license agreements.  The ASF licenses this file to You
+* under the Apache License, Version 2.0 (the "License"); you may not
+* use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+*     http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.  For additional information regarding
+* copyright in this work, please see the NOTICE file in the top level
+* directory of this distribution.
+*/
 package org.apache.abdera.protocol.client.util;
+
 import java.io.FileInputStream;
 import java.io.IOException;
 import java.net.InetAddress;
@@ -18,24 +36,6 @@
 import org.apache.commons.httpclient.ConnectTimeoutException;
 import org.apache.commons.httpclient.params.HttpConnectionParams;
 import org.apache.commons.httpclient.protocol.SecureProtocolSocketFactory;
-
-/*
-* Licensed to the Apache Software Foundation (ASF) under one or more
-* contributor license agreements.  The ASF licenses this file to You
-* under the Apache License, Version 2.0 (the "License"); you may not
-* use this file except in compliance with the License.
-* You may obtain a copy of the License at
-*
-*     http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.  For additional information regarding
-* copyright in this work, please see the NOTICE file in the top level
-* directory of this distribution.
-*/
 
 public class ClientAuthSSLProtocolSocketFactory 
   implements SecureProtocolSocketFactory {



Mime
View raw message