M
Mark Riordan
In my client application, I upload huge files via HTTP.
The URLConnection class seems to automatically buffer
the entire contents, then when the OutputStream associated with
the URLConnection is closed, it computes the length
and prepends a Content-Length header before actually sending
any bytes to the web server.
This results in an OutOfMemoryException when the file is huge.
My application uses Transfer-Encoding: chunked, but
that doesn't help when the entire stream gets buffered anyway.
Is there a way around this without writing my own URLConnection
clone based on Sockets? Calling flush() on the OutputStream
seems to have no effect.
I understand that a workaround would be to use the new features
of Java 1.5, but that's too new to expect end users to have.
Any help would be appreciated.
Thanks!
Mark Riordan
Note: email address in header, (e-mail address removed), must have
"NoSpam" removed.
The URLConnection class seems to automatically buffer
the entire contents, then when the OutputStream associated with
the URLConnection is closed, it computes the length
and prepends a Content-Length header before actually sending
any bytes to the web server.
This results in an OutOfMemoryException when the file is huge.
My application uses Transfer-Encoding: chunked, but
that doesn't help when the entire stream gets buffered anyway.
Is there a way around this without writing my own URLConnection
clone based on Sockets? Calling flush() on the OutputStream
seems to have no effect.
I understand that a workaround would be to use the new features
of Java 1.5, but that's too new to expect end users to have.
Any help would be appreciated.
Thanks!
Mark Riordan
Note: email address in header, (e-mail address removed), must have
"NoSpam" removed.