Unfortunately for those of us who rely on Tomcat to host our DAV implementations, Tomcat automatically processes the expect: 100-continue, taking away the opportunity for the server to investigate the permissions on such a request prior to receiving the entire body.
My suggestion to Matt would be perhaps to look at extending the PutMethod to enable the resupply of the stream in the manner of his choosing, by overriding writeRequestBody().
-Eric.
Oleg Kalnichevski wrote:
Hi Matt,
The problem is that a stream can only be read from once, hence,
unbuffered POST & POST content cannot be repeated.
There's a another (probably better) solution to this problem. All you have to do is to activate 'expect: 100-continue' handshake. Refer to the javadoc below for details
http://jakarta.apache.org/commons/httpclient/apidocs/org/apache/commons/httpclient/methods/ExpectContinueMethod.html#setUseExpectHeader(boolean)
Hope this helps
Oleg
On Tue, 2003-09-23 at 19:15, Rezvani, Matt wrote:
When setting the request content length of an enclosed entity to be stored on the WebDAV server using the PutMethod, the HttpClient returns an "Unbuffered entity enclosing request can not be repeated" HttpException. I am aware that if the request is not buffered, then the PutMethod (or PostMethod) cannot retry the request in case of an authentication challenge or an I/O error. An alternate solution would be to let the PutMethod buffer the entire file by setting the request content length to EntityEnclosingMethod.CONTENT_LENGTH_AUTO. This is OK for small files; however for enormous size files it causes an out-of-memory error. My question is how do I send a retry request after an authentication challenge has been sent back by the server, and why can't the EntityEnclosingMethod.writeRequestBody() send the request again from it's requestStream.
Here is a sample code.
//-------------------------- import org.apache.commons.httpclient.HttpClient; import org.apache.commons.httpclient.UsernamePasswordCredentials; import org.apache.commons.httpclient.methods.PutMethod; import java.io.*;
public class PutMethodExample { public static void main(String args[]) throws Exception { HttpClient client = new HttpClient(); // Assuming that the credentials are passed to the HttpClient using // the HttpState.setCredentials
PutMethod put = new PutMethod("http://myServer:/webdav/example.txt"); File bigFile = new File("c:\\j2sdk-1_4_2-windows-i586.exe"); long fileLength = bigFile.length(); put.setRequestContentLength((int)fileLength); put.setRequestBody(new FileInputStream(bigFile));
int status = client.executeMethod(put); put.releaseConnection(); } }
Thanks, Matt
--------------------------------------------------------------------- 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]
