Hi Pierre-Alain,

I'm trying to stream a GET response directly to a PUT method but I get a
"java.io.IOException: Stream closed" exception in order to synchronize 2
DAV repositories. I would like to avoid to deal with temporary files.

You can found my attempt here : http://pastebin.com/f5cef9454

Can somebody point me where I'm wrong?

You are using a single HttpClient with the default connection manager
to do two things at the same time. That cannot work. The default is
SimpleHttpConnectionManager [1], which always has only one connection.
First, you use that connection to execute the GET and obtain the result.
But when you try to use that same connection for sending the PUT, it
gets closed and re-opened to the new target. Then when it is time to
read from the GET, the stream is detected as closed.

Use two different HttpClient objects for the two requests, or create
one HttpClient object with a MultiThreadedHttpConnectionManager [2].
You might want to study the Threading Guide [3] first.

cheers,
  Roland

[1] http://hc.apache.org/httpclient-3.x/apidocs/org/apache/commons/httpclient/SimpleHttpConnectionManager.html [2] http://hc.apache.org/httpclient-3.x/apidocs/org/apache/commons/httpclient/MultiThreadedHttpConnectionManager.html
[3] http://hc.apache.org/httpclient-3.x/threading.html



Thanks for help.


StackTrace
-----------------------------
Exception in thread "main" java.io.IOException: Stream closed
        at
java.io.BufferedInputStream.getBufIfOpen(BufferedInputStream.java:145)
        at java.io.BufferedInputStream.read(BufferedInputStream.java:308)
        at java.io.FilterInputStream.read(FilterInputStream.java:90)
        at fr.ippon.webdav.Test$FileRequestEntity.writeRequest(Test.java:66)
        at
org.apache.commons.httpclient.methods.EntityEnclosingMethod.writeRequestBody(EntityEnclosingMethod.java:495)
        at
org.apache.commons.httpclient.HttpMethodBase.writeRequest(HttpMethodBase.java:1973)
        at
org.apache.commons.httpclient.HttpMethodBase.execute(HttpMethodBase.java:993)
        at
org.apache.commons.httpclient.HttpMethodDirector.executeWithRetry(HttpMethodDirector.java:397)
        at
org.apache.commons.httpclient.HttpMethodDirector.executeMethod(HttpMethodDirector.java:170)
        at
org.apache.commons.httpclient.HttpClient.executeMethod(HttpClient.java:396)
        at
org.apache.commons.httpclient.HttpClient.executeMethod(HttpClient.java:324)
        at fr.ippon.webdav.Test.main(Test.java:34)


---------------------------------------------------------------------
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