Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGreg Wilkins2014-06-04 09:05:34 -0400
committerGreg Wilkins2014-06-04 09:05:34 -0400
commite8fcb90bc22e838db9c1e7261e49eb1526fd1cf0 (patch)
tree737d97ef0e111b6c246715ee7d62e5608b2f6f12 /jetty-servlet
parentac4f8a26b70c855af6446c63af3340559db7d06e (diff)
downloadorg.eclipse.jetty.project-e8fcb90bc22e838db9c1e7261e49eb1526fd1cf0.tar.gz
org.eclipse.jetty.project-e8fcb90bc22e838db9c1e7261e49eb1526fd1cf0.tar.xz
org.eclipse.jetty.project-e8fcb90bc22e838db9c1e7261e49eb1526fd1cf0.zip
DefaultServlet uses cached headers
Diffstat (limited to 'jetty-servlet')
-rw-r--r--jetty-servlet/src/main/java/org/eclipse/jetty/servlet/DefaultServlet.java19
1 files changed, 13 insertions, 6 deletions
diff --git a/jetty-servlet/src/main/java/org/eclipse/jetty/servlet/DefaultServlet.java b/jetty-servlet/src/main/java/org/eclipse/jetty/servlet/DefaultServlet.java
index 792307cfe3..c3787395d3 100644
--- a/jetty-servlet/src/main/java/org/eclipse/jetty/servlet/DefaultServlet.java
+++ b/jetty-servlet/src/main/java/org/eclipse/jetty/servlet/DefaultServlet.java
@@ -38,7 +38,9 @@ import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.eclipse.jetty.http.HttpContent;
+import org.eclipse.jetty.http.HttpField;
import org.eclipse.jetty.http.HttpFields;
+import org.eclipse.jetty.http.HttpGenerator.CachedHttpField;
import org.eclipse.jetty.http.HttpHeader;
import org.eclipse.jetty.http.HttpMethod;
import org.eclipse.jetty.http.MimeTypes;
@@ -136,6 +138,9 @@ public class DefaultServlet extends HttpServlet implements ResourceFactory
private static final Logger LOG = Log.getLogger(DefaultServlet.class);
private static final long serialVersionUID = 4930458713846881193L;
+
+ private static final CachedHttpField ACCEPT_RANGES = new CachedHttpField(HttpHeader.ACCEPT_RANGES, "bytes");
+
private ServletContext _servletContext;
private ContextHandler _contextHandler;
@@ -155,7 +160,7 @@ public class DefaultServlet extends HttpServlet implements ResourceFactory
private String[] _welcomes;
private Resource _stylesheet;
private boolean _useFileMappedBuffer=false;
- private String _cacheControl;
+ private HttpField _cacheControl;
private String _relativeResourceBase;
private ServletHandler _servletHandler;
private ServletHolder _defaultHolder;
@@ -228,8 +233,10 @@ public class DefaultServlet extends HttpServlet implements ResourceFactory
LOG.debug(e);
}
- _cacheControl=getInitParameter("cacheControl");
-
+ String cc=getInitParameter("cacheControl");
+ if (cc!=null)
+ _cacheControl=new CachedHttpField(HttpHeader.CACHE_CONTROL, cc);
+
String resourceCache = getInitParameter("resourceCache");
int max_cache_size=getInitInt("maxCacheSize", -2);
int max_cached_file_size=getInitInt("maxCachedFileSize", -2);
@@ -1062,10 +1069,10 @@ public class DefaultServlet extends HttpServlet implements ResourceFactory
protected void writeOptionHeaders(HttpFields fields)
{
if (_acceptRanges)
- fields.put(HttpHeader.ACCEPT_RANGES,"bytes");
+ fields.put(ACCEPT_RANGES);
if (_cacheControl!=null)
- fields.put(HttpHeader.CACHE_CONTROL,_cacheControl);
+ fields.put(_cacheControl);
}
/* ------------------------------------------------------------ */
@@ -1075,7 +1082,7 @@ public class DefaultServlet extends HttpServlet implements ResourceFactory
response.setHeader(HttpHeader.ACCEPT_RANGES.asString(),"bytes");
if (_cacheControl!=null)
- response.setHeader(HttpHeader.CACHE_CONTROL.asString(),_cacheControl);
+ response.setHeader(HttpHeader.CACHE_CONTROL.asString(),_cacheControl.getValue());
}
/* ------------------------------------------------------------ */

Back to the top