You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@shindig.apache.org by li...@apache.org on 2010/01/11 20:11:02 UTC
svn commit: r898009 - in /incubator/shindig/trunk/java/common/src:
main/java/org/apache/shindig/common/servlet/HttpUtil.java
test/java/org/apache/shindig/common/servlet/HttpUtilTest.java
Author: lindner
Date: Mon Jan 11 19:11:02 2010
New Revision: 898009
URL: http://svn.apache.org/viewvc?rev=898009&view=rev
Log:
SHINDIG-1259 | Patch from Jon Weygandt | Added ability to control what 'cache forever' means
Modified:
incubator/shindig/trunk/java/common/src/main/java/org/apache/shindig/common/servlet/HttpUtil.java
incubator/shindig/trunk/java/common/src/test/java/org/apache/shindig/common/servlet/HttpUtilTest.java
Modified: incubator/shindig/trunk/java/common/src/main/java/org/apache/shindig/common/servlet/HttpUtil.java
URL: http://svn.apache.org/viewvc/incubator/shindig/trunk/java/common/src/main/java/org/apache/shindig/common/servlet/HttpUtil.java?rev=898009&r1=898008&r2=898009&view=diff
==============================================================================
--- incubator/shindig/trunk/java/common/src/main/java/org/apache/shindig/common/servlet/HttpUtil.java (original)
+++ incubator/shindig/trunk/java/common/src/main/java/org/apache/shindig/common/servlet/HttpUtil.java Mon Jan 11 19:11:02 2010
@@ -27,7 +27,7 @@
*/
public class HttpUtil {
// 1 year.
- public static final int DEFAULT_TTL = 60 * 60 * 24 * 365;
+ private static int defaultTtl = 60 * 60 * 24 * 365;
private static TimeSource timeSource;
@@ -46,7 +46,7 @@
* @param response The HTTP response
*/
public static void setCachingHeaders(HttpServletResponse response) {
- setCachingHeaders(response, DEFAULT_TTL, false);
+ setCachingHeaders(response, defaultTtl, false);
}
/**
@@ -57,7 +57,7 @@
* @param noProxy True if you don't want the response to be cacheable by proxies.
*/
public static void setCachingHeaders(HttpServletResponse response, boolean noProxy) {
- setCachingHeaders(response, DEFAULT_TTL, noProxy);
+ setCachingHeaders(response, defaultTtl, noProxy);
}
/**
@@ -99,4 +99,12 @@
}
}
}
+
+ public static int getDefaultTtl() {
+ return defaultTtl;
+ }
+
+ public static void setDefaultTtl(int defaultTtl) {
+ defaultTtl = defaultTtl;
+ }
}
Modified: incubator/shindig/trunk/java/common/src/test/java/org/apache/shindig/common/servlet/HttpUtilTest.java
URL: http://svn.apache.org/viewvc/incubator/shindig/trunk/java/common/src/test/java/org/apache/shindig/common/servlet/HttpUtilTest.java?rev=898009&r1=898008&r2=898009&view=diff
==============================================================================
--- incubator/shindig/trunk/java/common/src/test/java/org/apache/shindig/common/servlet/HttpUtilTest.java (original)
+++ incubator/shindig/trunk/java/common/src/test/java/org/apache/shindig/common/servlet/HttpUtilTest.java Mon Jan 11 19:11:02 2010
@@ -50,20 +50,20 @@
@Test
public void testSetCachingHeaders() {
HttpUtil.setCachingHeaders(recorder);
- checkCacheControlHeaders(testStartTime, recorder, HttpUtil.DEFAULT_TTL, false);
+ checkCacheControlHeaders(testStartTime, recorder, HttpUtil.getDefaultTtl(), false);
}
@Test
public void testSetCachingHeadersNoProxy() {
HttpUtil.setCachingHeaders(recorder, true);
- checkCacheControlHeaders(testStartTime, recorder, HttpUtil.DEFAULT_TTL, true);
+ checkCacheControlHeaders(testStartTime, recorder, HttpUtil.getDefaultTtl(), true);
}
@Test
public void testSetCachingHeadersAllowProxy() {
HttpUtil.setCachingHeaders(recorder, false);
- checkCacheControlHeaders(testStartTime, recorder, HttpUtil.DEFAULT_TTL, false);
+ checkCacheControlHeaders(testStartTime, recorder, HttpUtil.getDefaultTtl(), false);
}
@Test