JETTY-983 Default servlet sets accept-ranges for cached and gzip content

git-svn-id: svn+ssh://dev.eclipse.org/svnroot/rt/org.eclipse.jetty/jetty/trunk@163 7e9141cc-0065-0410-87d8-b60c137991c4
This commit is contained in:
Greg Wilkins 2009-04-20 07:39:38 +00:00
parent 6ff10dd433
commit 3999080ee8
3 changed files with 33 additions and 14 deletions

View File

@ -4,6 +4,7 @@ jetty-7.0.0.M1-SNAPSHOT
+ Removed HTTPConnection specifics from connection dispatching + Removed HTTPConnection specifics from connection dispatching
+ JETTY-695 Handler dump + JETTY-695 Handler dump
+ Reworked authentication for deferred authentication + Reworked authentication for deferred authentication
+ JETTY-983 DefaultServlet generates accept-ranges for cached/gzip content
jetty-7.0.0.M0 jetty-7.0.0.M0

View File

@ -527,6 +527,14 @@ public class ResourceCache extends AbstractLifeCycle implements Serializable
{ {
return _resource.getInputStream(); return _resource.getInputStream();
} }
/* ------------------------------------------------------------ */
public String toString()
{
return "{"+_resource+","+_contentType+","+_lastModifiedBytes+"}";
}
} }

View File

@ -662,8 +662,7 @@ public class DefaultServlet extends HttpServlet implements ResourceFactory
{ {
if (response instanceof Response) if (response instanceof Response)
{ {
if (_cacheControl!=null) writeOptionHeaders(((Response)response).getHttpFields());
((Response)response).getHttpFields().put(HttpHeaders.CACHE_CONTROL_BUFFER,_cacheControl);
((HttpConnection.Output)out).sendContent(content); ((HttpConnection.Output)out).sendContent(content);
} }
else else
@ -777,7 +776,7 @@ public class DefaultServlet extends HttpServlet implements ResourceFactory
protected void writeHeaders(HttpServletResponse response,HttpContent content,long count) protected void writeHeaders(HttpServletResponse response,HttpContent content,long count)
throws IOException throws IOException
{ {
if (content.getContentType()!=null) if (content.getContentType()!=null && response.getContentType()==null)
response.setContentType(content.getContentType().toString()); response.setContentType(content.getContentType().toString());
if (response instanceof Response) if (response instanceof Response)
@ -797,12 +796,7 @@ public class DefaultServlet extends HttpServlet implements ResourceFactory
if (count != -1) if (count != -1)
r.setLongContentLength(count); r.setLongContentLength(count);
if (_acceptRanges) writeOptionHeaders(fields);
fields.put(HttpHeaders.ACCEPT_RANGES_BUFFER,HttpHeaderValues.BYTES_BUFFER);
if (_cacheControl!=null)
fields.put(HttpHeaders.CACHE_CONTROL_BUFFER,_cacheControl);
} }
else else
{ {
@ -817,15 +811,31 @@ public class DefaultServlet extends HttpServlet implements ResourceFactory
else else
response.setHeader(HttpHeaders.CONTENT_LENGTH,TypeUtil.toString(count)); response.setHeader(HttpHeaders.CONTENT_LENGTH,TypeUtil.toString(count));
} }
if (_acceptRanges)
response.setHeader(HttpHeaders.ACCEPT_RANGES,"bytes");
if (_cacheControl!=null) writeOptionHeaders(response);
response.setHeader(HttpHeaders.CACHE_CONTROL,_cacheControl.toString());
} }
} }
/* ------------------------------------------------------------ */
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() * @see javax.servlet.Servlet#destroy()