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:
parent
6ff10dd433
commit
3999080ee8
|
@ -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
|
||||
|
|
|
@ -527,6 +527,14 @@ public class ResourceCache extends AbstractLifeCycle implements Serializable
|
|||
{
|
||||
return _resource.getInputStream();
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
public String toString()
|
||||
{
|
||||
return "{"+_resource+","+_contentType+","+_lastModifiedBytes+"}";
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -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()
|
||||
|
|
Loading…
Reference in New Issue