TheProjecter / sardine

Automatically exported from code.google.com/p/sardine
0 stars 0 forks source link

MOVE should specify Content-Length: 0 #134

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
Use Sardine perform a MOVE (sardine.move(source, destination);) on a Milton 
Webdav 1.8 server on Tomcat 7.

What is the expected output? What do you see instead?
I expect the file to be moved, instead Sardine hangs waiting for something to 
happen.

What version of the product are you using?
r314 from http://sardine.googlecode.com/svn/maven/

On what operating system?
Windows Vista 32 bit

What webdav server are you hitting?
Own server using Milton Webdav 1.8 on Tomcat 7

What is in the server error logs?
A thread dump shows it's waiting for data:
   java.lang.Thread.State: RUNNABLE
    at java.net.SocketInputStream.socketRead0(Native Method)
    at java.net.SocketInputStream.read(SocketInputStream.java:129)
    at java.io.BufferedInputStream.fill(BufferedInputStream.java:218)
    at java.io.BufferedInputStream.read(BufferedInputStream.java:237)
    - locked <0x04ac20c0> (a java.io.BufferedInputStream)
    at java.io.FilterInputStream.read(FilterInputStream.java:66)
    at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:517)
    at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(TCPTransport.java:790)
    at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:649)
    at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
    at java.lang.Thread.run(Thread.java:662)

   Locked ownable synchronizers:
    - <0x04ad05e0> (a java.util.concurrent.locks.ReentrantLock$NonfairSync)

It works great if I add the header:

public class FixedSardineImpl extends SardineImpl {
    @Override
    public void move(String sourceUrl, String destinationUrl) throws IOException {
        HttpMove move = new HttpMove(sourceUrl, destinationUrl);
        move.addHeader(HttpHeaders.CONTENT_LENGTH, "0");
        this.execute(move, new VoidResponseHandler());
    }
}

This should probably be done in the constructor of HttpMove though.

Original issue reported on code.google.com by gerardk...@gmail.com on 26 Nov 2012 at 3:44

GoogleCodeExporter commented 9 years ago
The thread dump posted shows that it is waiting on some RMI connection. The 
request does not contain a message body and therefore as far as I know HTTP 
does not mandate a content length header.

Original comment by dkocher@sudo.ch on 18 Apr 2013 at 8:19