Hello Jen,
Another way to handle this problem is to use the "expect 100 continue" feature of HTTP. This feature is disabled in HttpClient by default, as only a few servers support it correctly. You can re-enable it by calling setUseExpectHeader(true) on the post method.
Mike
On Jul 13, 2004, at 6:42 PM, Jennifer Ward wrote:
Yes, setting CONTENT_LENGTH_AUTO does buffer the content. However, in doing this I realized it's not really the best solution since the content will get sent twice (although, it gets ignored the first time). So, it's not efficient.
In retrospect what I really want to do is establish the connection once (perhaps by sending an OPTIONS request), retain the digest challenge string, then send each subsequent request (including puts) with the appropriate auth header.
Now, I'm trying to go through the HttpAuthenticator code and figure out how to do that. If anyone has any experience with this I would appreciate hearing about it. I am fairly new to HttpClient.
Thanks for your input, Jen
On Jul 13, 2004, at 3:34 AM, Michael Becke wrote:
Yes, HttpClient will buffer the content if you use CONTENT_LENGTH_AUTO.
Mike
On Jul 13, 2004, at 3: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]
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]