You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@jakarta.apache.org by se...@apache.org on 2010/12/10 03:14:38 UTC
svn commit: r1044198 -
/jakarta/jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/control/CacheManager.java
Author: sebb
Date: Fri Dec 10 02:14:38 2010
New Revision: 1044198
URL: http://svn.apache.org/viewvc?rev=1044198&view=rev
Log:
Add method for Apache HttpClient
Modified:
jakarta/jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/control/CacheManager.java
Modified: jakarta/jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/control/CacheManager.java
URL: http://svn.apache.org/viewvc/jakarta/jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/control/CacheManager.java?rev=1044198&r1=1044197&r2=1044198&view=diff
==============================================================================
--- jakarta/jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/control/CacheManager.java (original)
+++ jakarta/jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/control/CacheManager.java Fri Dec 10 02:14:38 2010
@@ -33,6 +33,7 @@ import org.apache.commons.httpclient.URI
import org.apache.commons.httpclient.util.DateParseException;
import org.apache.commons.httpclient.util.DateUtil;
import org.apache.http.HttpResponse;
+import org.apache.http.client.methods.HttpRequestBase;
import org.apache.jmeter.config.ConfigTestElement;
import org.apache.jmeter.engine.event.LoopIterationEvent;
import org.apache.jmeter.protocol.http.util.HTTPConstantsInterface;
@@ -199,13 +200,14 @@ public class CacheManager extends Config
* Check the cache, and if there is a match, set the headers:<br/>
* If-Modified-Since<br/>
* If-None-Match<br/>
+ * Commons HttpClient version
* @param url URL to look up in cache
* @param method where to set the headers
*/
public void setHeaders(URL url, HttpMethod method) {
CacheEntry entry = getCache().get(url.toString());
if (log.isDebugEnabled()){
- log.debug(method.getName()+"(OAHC) "+url.toString()+" "+entry);
+ log.debug(method.getName()+"(OACH) "+url.toString()+" "+entry);
}
if (entry != null){
final String lastModified = entry.getLastModified();
@@ -223,6 +225,31 @@ public class CacheManager extends Config
* Check the cache, and if there is a match, set the headers:<br/>
* If-Modified-Since<br/>
* If-None-Match<br/>
+ * Apache HttpClient version.
+ * @param url URL to look up in cache
+ * @param request where to set the headers
+ */
+ public void setHeaders(URL url, HttpRequestBase request) {
+ CacheEntry entry = getCache().get(url.toString());
+ if (log.isDebugEnabled()){
+ log.debug(request.getMethod()+"(OAH) "+url.toString()+" "+entry);
+ }
+ if (entry != null){
+ final String lastModified = entry.getLastModified();
+ if (lastModified != null){
+ request.setHeader(HTTPConstantsInterface.IF_MODIFIED_SINCE, lastModified);
+ }
+ final String etag = entry.getEtag();
+ if (etag != null){
+ request.setHeader(HTTPConstantsInterface.IF_NONE_MATCH, etag);
+ }
+ }
+ }
+
+ /**
+ * Check the cache, and if there is a match, set the headers:<br/>
+ * If-Modified-Since<br/>
+ * If-None-Match<br/>
* @param url URL to look up in cache
* @param conn where to set the headers
*/
@@ -324,4 +351,5 @@ public class CacheManager extends Config
}
useExpires=getUseExpires(); // cache the value
}
+
}
\ No newline at end of file
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@jakarta.apache.org
For additional commands, e-mail: notifications-help@jakarta.apache.org