Jennifer,

I just recently had to respond to a very similar question. 

http://marc.theaimsgroup.com/?l=httpclient-commons-dev&m=108940676906963&w=2

To recap, whenever request body is streamed out (read directly from an
input stream) the request cannot be _automatically_ repeated.

There are three possibilities to fix the problem:

1) ensure that content is buffered by setting request length to
CONTENT_LENGTH_AUTO (must be used sparingly)

2) avoid having to repeat the request due to an authentication or I/O
failure

3) re-instantiate the input stream and retry the request manually

The second option is preferred. However, in order to make this option
feasible you have to determined what caused the initial request fail in
the first place

In your particular instance my <strong>guess</strong> is the problem has
been caused by the fact that only Basic authentication scheme can be
used when authenticating preemptively. Your attempt to activate Digest
authentication makes preemptive authentication fail, thus causing the
method retry, which in its turn fails due to unbuffered content. 

I believe the best solution could be using the 'expect: continue'
handshake. Refer to the following document for details

http://jakarta.apache.org/commons/httpclient/apidocs/org/apache/commons/httpclient/methods/ExpectContinueMethod.html

Hope this helps

Oleg


On Tue, 2004-07-13 at 20:05, Jennifer Ward wrote:
> Thanks for the reply. Unfortunately, I tried setting the Content-Length 
> header (no chunked transfer encoding), but that didn't work either.
> 
> I would appreciate any other suggestions you may have.
> 
> Sincerely,
> Jennifer Ward
> 
> On Jul 13, 2004, at 12:20 AM, Ingo Brunberg wrote:
> 
> > The problem is that you are using chunked transfer encoding. This
> > prevents Httpclient to automatically buffer the content in memory and
> > the InputStream can only be read once.
> >
> > The workaround is simply to provide the exact content-length.
> >
> > Ingo
> >
> >> Hi,
> >>
> >> I wonder if anyone could offer a suggestion for getting around an
> >> exception I'm seeing.
> >>
> >> I am writing a load test client that sends requests to a webdav 
> >> server.
> >> I have a putMethod which does the following:
> >>
> >>                    PutMethod method = new 
> >> PutMethod(URIUtil.encodePathQuery(path));
> >>                    generateIfHeader(method);
> >>                    if (getGetContentType() != null && 
> >> !getGetContentType().equals(""))
> >>                            method.setRequestHeader("Content-Type", 
> >> getGetContentType());
> >>                    
> >> method.setRequestContentLength(PutMethod.CONTENT_LENGTH_CHUNKED);
> >>                    method.setRequestBody(bis);
> >>                    int statusCode = client.executeMethod(method);
> >>
> >> bis is a BufferedInputStream.
> >>
> >> This method works fine when sending requests using Basic
> >> authentication. However, I want to use Digest authentication (I have
> >> setAuthenticationPreemptive set to false). When sending the request
> >> using Digest, I get the exception:
> >>
> >> org.apache.commons.httpclient.HttpException: Unbuffered entity
> >> enclosing request can not be repeated.
> >>
> >> In looking at the code, it appears that
> >> EntityEnclosingMethod.writeRequestBody does not cache the request 
> >> body.
> >> So, when the request is resent (with the digest auth header), the
> >> contentCache is null, thus the exception.
> >>
> >> Does anyone know of a way around this?
> >>
> >> Thanks,
> >> Jennifer
> >
> >
> > ---------------------------------------------------------------------
> > 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