mirror of https://github.com/apache/jmeter.git
Bug 51932 - CacheManager does not handle cache-control header with any attributes after max-age
git-svn-id: https://svn.apache.org/repos/asf/jakarta/jmeter/trunk@1177871 13f79535-47bb-0310-9956-ffa450edef68
Former-commit-id: adf085462a
This commit is contained in:
parent
e114e283e5
commit
11bf4bc223
|
|
@ -158,8 +158,11 @@ public class CacheManager extends ConfigTestElement implements TestListener, Ser
|
|||
final String MAX_AGE = "max-age=";
|
||||
// TODO - check for other CacheControl attributes?
|
||||
if (cacheControl != null && cacheControl.contains("public") && cacheControl.contains(MAX_AGE)) {
|
||||
long maxAge = Long.parseLong(cacheControl.substring(cacheControl.indexOf(MAX_AGE)+MAX_AGE.length()))*1000;
|
||||
expiresDate=new Date(System.currentTimeMillis()+maxAge);
|
||||
long maxAgeInSecs = Long.parseLong(
|
||||
cacheControl.substring(cacheControl.indexOf(MAX_AGE)+MAX_AGE.length())
|
||||
.split("[, ]")[0] // Bug 51932 - allow for optional trailing attributes
|
||||
);
|
||||
expiresDate=new Date(System.currentTimeMillis()+maxAgeInSecs*1000);
|
||||
} else if (expires != null) {
|
||||
try {
|
||||
expiresDate = DateUtil.parseDate(expires);
|
||||
|
|
|
|||
|
|
@ -226,6 +226,18 @@ public class TestCacheManager extends JMeterTestCase {
|
|||
assertTrue("Should find valid entry",this.cacheManager.inCache(url));
|
||||
}
|
||||
|
||||
public void testCacheHttpClientBug51932() throws Exception{
|
||||
this.cacheManager.setUseExpires(true);
|
||||
this.cacheManager.testIterationStart(null);
|
||||
assertNull("Should not find entry",getThreadCacheEntry(LOCAL_HOST));
|
||||
assertFalse("Should not find valid entry",this.cacheManager.inCache(url));
|
||||
((HttpMethodStub)httpMethod).expires=makeDate(new Date(System.currentTimeMillis()));
|
||||
((HttpMethodStub)httpMethod).cacheControl="public, max-age=10, no-transform";
|
||||
this.cacheManager.saveDetails(httpMethod, sampleResultOK);
|
||||
assertNotNull("Should find entry",getThreadCacheEntry(LOCAL_HOST));
|
||||
assertTrue("Should find valid entry",this.cacheManager.inCache(url));
|
||||
}
|
||||
|
||||
public void testGetClearEachIteration() throws Exception {
|
||||
assertFalse("Should default not to clear after each iteration.", this.cacheManager.getClearEachIteration());
|
||||
this.cacheManager.setClearEachIteration(true);
|
||||
|
|
|
|||
|
|
@ -29,6 +29,13 @@
|
|||
Earlier changes are detailed in the <a href="changes_history.html">History of Previous Changes</a>.
|
||||
</note>
|
||||
|
||||
<h1>Version 2.5.2?</h1>
|
||||
<p>temporary section to collect changes while release vote is in progress</p>
|
||||
<ul>
|
||||
<li>Bug 51932 - CacheManager does not handle cache-control header with any attributes after max-age</li>
|
||||
</ul>
|
||||
|
||||
|
||||
<!-- =================== -->
|
||||
|
||||
<h1>Version 2.5.1</h1>
|
||||
|
|
|
|||
Loading…
Reference in New Issue