416663 Content-length set by resourcehandler

This commit is contained in:
Greg Wilkins 2013-09-06 09:18:22 +10:00
parent b8a4bf37e6
commit ee52769dea
3 changed files with 7 additions and 7 deletions

View File

@ -135,10 +135,10 @@ public class Response implements HttpServletResponse
Response response = _channel.getResponse();
String contentType = httpContent.getContentType();
if (contentType != null && !response.getHttpFields().containsKey(HttpHeader.CONTENT_TYPE.asString()))
response.getHttpFields().put(HttpHeader.CONTENT_TYPE, contentType);
setContentType(contentType);
if (httpContent.getContentLength() > 0)
response.getHttpFields().putLongField(HttpHeader.CONTENT_LENGTH, httpContent.getContentLength());
setLongContentLength(httpContent.getContentLength());
String lm = httpContent.getLastModified();
if (lm != null)

View File

@ -602,19 +602,20 @@ public class ResourceHandler extends HandlerWrapper
HttpFields fields = ((Response)response).getHttpFields();
if (length>0)
fields.putLongField(HttpHeader.CONTENT_LENGTH,length);
((Response)response).setLongContentLength(length);
if (_cacheControl!=null)
fields.put(HttpHeader.CACHE_CONTROL,_cacheControl);
}
else
{
if (length>0)
if (length>Integer.MAX_VALUE)
response.setHeader(HttpHeader.CONTENT_LENGTH.asString(),Long.toString(length));
else if (length>0)
response.setContentLength((int)length);
if (_cacheControl!=null)
response.setHeader(HttpHeader.CACHE_CONTROL.asString(),_cacheControl.toString());
}
}
}

View File

@ -988,7 +988,6 @@ public class DefaultServlet extends HttpServlet implements ResourceFactory
else
// Handle cached resource
(resource).writeTo(multi,start,size);
}
if (in!=null)
in.close();