if ((outputType != null) && outputType.equals("binary"))
{
// Binary data, so dump to output stream now....
log.debug("File Data is available");
final BinaryWrapper data = (BinaryWrapper) ((Output) re).getContent();
// hres.setContentLength(new
// Integer(((Long)re.getAttribute("ContentLength")).toString()).intValue());
final long dataSize = data.getSize();
if ((dataSize > 0) && (dataSize < Integer.MAX_VALUE))
{
// Have a valid content length.
hres.setContentLength((int) data.getSize());
}
hres.setContentType(data.getContentType());
hres.setHeader("Content-Disposition", (String) re.getAttribute("Content-Disposition"));
// String encodings = hreq.getHeader ("Accept-Encoding");
BufferedOutputStream buffOut = null;
try
{
// BUG #844574:Writing using GZip compression is very
// slow
// HACK: Disable GZip compression until speed/threading
// issues are worked out.
// if (encodings != null && encodings.indexOf ("gzip") != -1)
// {
// log.info ("Writing data using GZip compression");
//
// final OutputStream out = hres.getOutputStream ();
//
// buffOut = new BufferedOutputStream(
// new GZIPOutputStream(out), BUFFER_SIZE);
// hres.setHeader ("Content-Encoding", "gzip");
// }
// else
// {
log.info("Writing data with no compression");
OutputStream out = hres.getOutputStream();
buffOut = new BufferedOutputStream(out, BUFFER_SIZE);
// }
data.writeTo(buffOut);
log.trace("Wrote Buffer.");
}
catch (IOException e)
{
e.printStackTrace();
log.error("Exception during file read/write:", e);
throw new ClientException("Exception during file read/write", e);
}
finally
{
// Flush all streams, and close input streams
try
{
data.close();
}
catch (IOException e1)
{
e1.printStackTrace();
}