commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Andreas Probst" <andpr...@gmx.net>
Subject Re: PutMethod with chunked transfer
Date Thu, 07 Aug 2003 21:20:35 GMT
Hi,

I found the solution, when I debugged through the code again:

To run unbuffered, ie. streamed, set requestContentLength to -1 
or the real content length. -1 means chunked. If it isn't set by 
the caller, it's set to -2 by default, which results i running 
buffered.

The code now looks like:

putMethod.setRequestBody(inputStream);
putMethod.setRequestContentLength(...);
_jakartaHttpClient.executeMethod(putMethod);

Andreas

On 6 Aug 2003 at 14:17, andpro77@gmx.net wrote:

> Hi all,
> 
> how is it possible to tell PutMethod to transfer data chunked?
> 
> I do
> 
> putMethod.setRequestBody(inputStream);
> _jakartaHttpClient.executeMethod(putMethod);
> 
> In EntityEnclosingMethod.writeRequestBody() it uses
> ChunkedOutputStream only
> 
> if (contentLength == CONTENT_LENGTH_CHUNKED)
> 
> However, before that it chooses to buffer the content and don't
> run chunked, if in generateRequestBody() requestStream != null.
> And this isn't null, as I set the inputStream above before
> execution. As a consequence, the contentLength is known, which
> causes writeRequestBody() not to use the ChunkedOutputStream.
> 
> So what did I miss here?
> 
> Another thing is: Can't HttpClient run streamed if I set the
> requestBody? As I observed, it chooses to buffer the content if
> an InputStream is set.
> 
> Thanks in advance.
> 
> Andreas
> 


Mime
View raw message