hc-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Michael Becke <be...@u.washington.edu>
Subject Re: Streaming requests
Date Thu, 04 Mar 2004 01:18:26 GMT
Hi David,

In the case of the piped streams you need to do the reading and writing 
from separate threads.  This is to avoid the exact case that you are 
seeing, and I believe it is documented in Sun's javadocs.  Any other 
solution will require changing the PostMethod API as discussed, or 
buffering.

Mike

On Mar 3, 2004, at 4:41 PM, David.Cowan@apcc.com wrote:

> 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: 
> commons-httpclient-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: 
> commons-httpclient-dev-help@jakarta.apache.org
>


---------------------------------------------------------------------
To unsubscribe, e-mail: commons-httpclient-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-httpclient-dev-help@jakarta.apache.org


Mime
View raw message