users@glassfish.java.net

Forcing chunked encoding while downloading a large file?

From: Kevin Regan <k.regan_at_f5.com>
Date: Fri, 4 May 2012 21:24:18 +0000

I'm downloading a large file with Jersey/Glassfish and I'm seeing a java.lang.OutOfMemoryError.

I'm returning a FileInputStream (also tried File) from the Jersey handler and it looks to be attempting to write the file to a ByteArrayOutputStream before returning it.

Is there any way to force Jersey/Glassfish to stream this large binary file to the client through either chunked encoding or by not setting CONTENT-LENGTH?

Sincerely,
Kevin Regan