HttpContent c = (HttpContent) content;
if (c.getContentType() != null && !_responseFields.containsKey(HttpHeaders.CONTENT_TYPE_BUFFER))
_responseFields.add(HttpHeaders.CONTENT_TYPE_BUFFER, c.getContentType());
if (c.getContentLength() > 0)
_responseFields.putLongField(HttpHeaders.CONTENT_LENGTH_BUFFER, c.getContentLength());
Buffer lm = c.getLastModified();
long lml=c.getResource().lastModified();
if (lm != null)
_responseFields.put(HttpHeaders.LAST_MODIFIED_BUFFER, lm,lml);
else if (c.getResource()!=null)
{
if (lml!=-1)
_responseFields.putDateField(HttpHeaders.LAST_MODIFIED_BUFFER, lml);
}
content = c.getBuffer();
if (content==null)
content=c.getInputStream();
}
else if (content instanceof Resource)
{
resource=(Resource)content;
_responseFields.putDateField(HttpHeaders.LAST_MODIFIED_BUFFER, resource.lastModified());
content=resource.getInputStream();
}
if (content instanceof Buffer)
{
_generator.addContent((Buffer) content, HttpGenerator.LAST);
commitResponse(HttpGenerator.LAST);
}
else if (content instanceof InputStream)
{
InputStream in = (InputStream)content;
try
{
int max = _generator.prepareUncheckedAddContent();
Buffer buffer = _generator.getUncheckedBuffer();
int len=buffer.readFrom(in,max);
while (len>=0)
{
_generator.completeUncheckedAddContent();
_out.flush();
max = _generator.prepareUncheckedAddContent();
buffer = _generator.getUncheckedBuffer();
len=buffer.readFrom(in,max);
}
_generator.completeUncheckedAddContent();
_out.flush();
}
finally