Hi Alessandro,

> the inputstream being passed to the constructor is not null. i've
> checked this by stepping through the code.

I know it isn't null. You would have gotten a different exception.
My question was: do you see an IOException in the log?

You can disable the auto-buffering behaviour by passing a content
length of -1 to the constructor:
http://jakarta.apache.org/commons/httpclient/apidocs/org/apache/commons/httpclient/methods/InputStreamRequestEntity.html#InputStreamRequestEntity(java.io.InputStream,%20long)

You can use this constant if you prefer to avoid hard-coded values:
http://jakarta.apache.org/commons/httpclient/apidocs/org/apache/commons/httpclient/methods/EntityEnclosingMethod.html#CONTENT_LENGTH_CHUNKED

This assumes you are sending with HTTP/1.1.

hope that helps,
  Roland


> -----Original Message-----
> From: Roland Weber [mailto:[EMAIL PROTECTED] 
> Sent: Friday, February 16, 2007 4:57 PM
> To: HttpClient User Discussion
> Subject: Re: IllegalStateException: Content must be set before entity is
> written
> 
> Hello Alessandro,
> 
>> by reading the bytes from 'item.openStream()' in a loop and logging 
>> the number of bytes processed i was able to verify that the 
>> 'item.openStream()' correctly returns the file content.
>> (i did this just befor the line where i would pass the stream to the
>> entity)
>>
>> the InputStreamRequestEntity's constructor seems to not be able to get
> 
>> the contents of the stream passed as argument ....?
> 
> It's not the constructor, but a private method called bufferContent():
> 
>             } catch (IOException e) {
>                 LOG.error(e.getMessage(), e);
>                 this.buffer = null;
>                 this.content = null;
>                 this.contentLength = 0;
>             }
> 
> Do you see an IOException in the log? The constructor would throw an
> IllegalArgumentException if the InputStream is null.
> 
> cheers,
>   Roland
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 


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

Reply via email to