diff --git a/VERSION.txt b/VERSION.txt index d91b19cf278..efe57fbc329 100644 --- a/VERSION.txt +++ b/VERSION.txt @@ -4,6 +4,7 @@ jetty-7.0.0.M1-SNAPSHOT + Removed HTTPConnection specifics from connection dispatching + JETTY-695 Handler dump + Reworked authentication for deferred authentication + + JETTY-983 DefaultServlet generates accept-ranges for cached/gzip content jetty-7.0.0.M0 diff --git a/jetty-server/src/main/java/org/eclipse/jetty/server/ResourceCache.java b/jetty-server/src/main/java/org/eclipse/jetty/server/ResourceCache.java index 09b3626015c..e2f1b54598f 100644 --- a/jetty-server/src/main/java/org/eclipse/jetty/server/ResourceCache.java +++ b/jetty-server/src/main/java/org/eclipse/jetty/server/ResourceCache.java @@ -527,6 +527,14 @@ public class ResourceCache extends AbstractLifeCycle implements Serializable { return _resource.getInputStream(); } + + /* ------------------------------------------------------------ */ + public String toString() + { + return "{"+_resource+","+_contentType+","+_lastModifiedBytes+"}"; + } + + } 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 7cf01f0acca..2a8190af660 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 @@ -662,8 +662,7 @@ public class DefaultServlet extends HttpServlet implements ResourceFactory { if (response instanceof Response) { - if (_cacheControl!=null) - ((Response)response).getHttpFields().put(HttpHeaders.CACHE_CONTROL_BUFFER,_cacheControl); + writeOptionHeaders(((Response)response).getHttpFields()); ((HttpConnection.Output)out).sendContent(content); } else @@ -777,7 +776,7 @@ public class DefaultServlet extends HttpServlet implements ResourceFactory protected void writeHeaders(HttpServletResponse response,HttpContent content,long count) throws IOException { - if (content.getContentType()!=null) + if (content.getContentType()!=null && response.getContentType()==null) response.setContentType(content.getContentType().toString()); if (response instanceof Response) @@ -797,12 +796,7 @@ public class DefaultServlet extends HttpServlet implements ResourceFactory if (count != -1) r.setLongContentLength(count); - if (_acceptRanges) - fields.put(HttpHeaders.ACCEPT_RANGES_BUFFER,HttpHeaderValues.BYTES_BUFFER); - - if (_cacheControl!=null) - fields.put(HttpHeaders.CACHE_CONTROL_BUFFER,_cacheControl); - + writeOptionHeaders(fields); } else { @@ -817,15 +811,31 @@ public class DefaultServlet extends HttpServlet implements ResourceFactory else response.setHeader(HttpHeaders.CONTENT_LENGTH,TypeUtil.toString(count)); } - - if (_acceptRanges) - response.setHeader(HttpHeaders.ACCEPT_RANGES,"bytes"); - if (_cacheControl!=null) - response.setHeader(HttpHeaders.CACHE_CONTROL,_cacheControl.toString()); + writeOptionHeaders(response); } } + /* ------------------------------------------------------------ */ + protected void writeOptionHeaders(HttpFields fields) throws IOException + { + if (_acceptRanges) + fields.put(HttpHeaders.ACCEPT_RANGES_BUFFER,HttpHeaderValues.BYTES_BUFFER); + + if (_cacheControl!=null) + fields.put(HttpHeaders.CACHE_CONTROL_BUFFER,_cacheControl); + } + + /* ------------------------------------------------------------ */ + protected void writeOptionHeaders(HttpServletResponse response) throws IOException + { + if (_acceptRanges) + response.setHeader(HttpHeaders.ACCEPT_RANGES,"bytes"); + + if (_cacheControl!=null) + response.setHeader(HttpHeaders.CACHE_CONTROL,_cacheControl.toString()); + } + /* ------------------------------------------------------------ */ /* * @see javax.servlet.Servlet#destroy()