I know there have been several discussions in regards to streaming requests
rather than buffering.  There have been many suggestions on how to allow
for streaming of requests using Piped streams, etc, but I have come up
against a situation were it seems to be impossible to do with the current
architecture.  I am using JDOM to generate XML and send it to the server
using httpclient.  The problem I am running into is that the xml can become
large enough that streaming would definately help on memory allocations.
The real stumbling block lies in the fact that JDOM expects an output
stream to write to and httpclient uses an input stream.  This would
normally be a great place to use Piped streams but in this instance it
doesn't work.

This example demonstrates the problem

PipedInputStream pipedInputStream = new PipedInputStream();
PipedOutputStream pipedOutputStream = new
PipedOutputStream(pipedInputStream);
XMLOutputter output = new XMLOutputter();

postMethod.setRequestBody(pipedInputStream);
output.output(doc, pipedOutputStream);   // calling this outputs to the
output stream but this hangs because the PipedInputStream is not read until
executeMethod
int statusCode = httpClient.executeMethod(postMethod);


The problem here is that calling output of course hangs because the
PipedInputStream is not being read until executMethod is called.  If there
was access to an output stream in postMethod this could be solved.  Does
anyone have any other ideas of how this could be accomplished?

Thanks in advance for any help.



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to