Please describe the problem.
git-annex's WebDAV support does not like (aka it does not work) the WebDAV server of the freenet cloud.
What steps will reproduce the problem?
My first attempt was:
WEBDAV_USERNAME='XXX' WEBDAV_PASSWORD='XXX' git annex initremote webdav type=webdav url='https://webmail.freenet.de/webdav' encryption=none
initremote webdav (testing WebDAV server...)
git-annex: WebDAV test failed: StatusCodeException (Status {statusCode = 401, statusMessage = "Unauthorized"}) [("Date","Fri, 04 Dec 2015 12:20:57 GMT"),("Server","Apache/2.2.16 (Debian)"),("WWW-Authenticate","Basic realm=\"MD-Cloud\""),
("Vary","Accept-Encoding"),("Content-Encoding","gzip"),("Content-Length","20"),("Connection","close"),("Content-Type","text/html; charset=iso-8859-15"),("X-Response-Body-Start",""),("X-Request-URL","MKCOL https://webmail.freenet.de:443/webdav/tmp")]
(CJ {expose = []}): user error failed
git-annex: initremote: 1 failed
Ok this fails (what is the error?). However, it does create a folder "tmp" in the "cloud". A second attempt yields another error:
WEBDAV_USERNAME='XXX' WEBDAV_PASSWORD='XXX' git annex initremote webdav type=webdav url='https://webmail.freenet.de/webdav' encryption=none
initremote webdav (testing WebDAV server...)
git-annex: WebDAV test failed: StatusCodeException (Status {statusCode = 501, statusMessage = "Not Implemented"}) [("Date","Fri, 04 Dec 2015 12:21:22 GMT"),("Server","Apache/2.2.16 (Debian)"),("Content-Length","349"),("Connection","close"),
("Content-Type","application/xml; charset=utf-8"),("X-Response-Body-Start","<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<d:error xmlns:d=\"DAV:\" xmlns:s=\"http://sabredav.org/ns\">\n <s:exception>Sabre\\DAV\\Exception\\NotImplemented</s:exception>\n
<s:message>This server is not compatible with OS/X finder. Consider using a different WebDAV client or webserver.</s:message>\n <s:sabredav-version>1.8.6</s:sabredav-version>\n</d:error>\n"),("X-Request-URL","PUT https://webmail.freenet.de:443/webdav
/tmp/git-annex-test")] (CJ {expose = []}): user error failed
git-annex: initremote: 1 failed
which is I guess the same. The WebDAV server does support writing and locking files. I tried writing using davfs2 and locking-unlocking using cadaver. I guess in the end that it's the server's fault, but it would be great to know what exactly fails at this point :).
What version of git-annex are you using? On what operating system?
git-annex version: 5.20151116-gbe86081
Gentoo Linux
Have you had any luck using git-annex before? (Sometimes we get tired of reading bug reports all day and a lil' positive end note does wonders)
First time trying WebDAV support.
ok, I could find the source of the problem: they use sabredav as WebDAV server and sabredav does not support chunked transfers:
Although, I did not told git-annex to chunk the transfer :-/, because I did not append a 'chunk' parameter. Any ideas how to fix that?
The first failure is git-annex sending MKCOL (make directory basically). The server fails with "Unauthorized". You say it also made the directory. That's got to be a bug in the server, no? It can't sanely have an authorization problem and also go on and do the unathorized action. (Sounds rather like a security hole..)
As to the PUT failure, the chunked transfer encoding mentioned in that comment is a regular part of the HTTP protocol (this is not connected to git-annex's own chunking). https://en.wikipedia.org/wiki/Chunked_transfer_encoding
Looks like this PHP webdav server might be delegating the actual HTTP to whatever web server it's running on somehow. Since chunked transfer encoding might not be supported by some web server, they are left trying to detect that. I don't know if their check for that is accurate.
As to the implementation in git-annex, Network.Http.Client.RequestBodyStreamChunked is documented to be the only thing that causes a chunked request body to be sent, and git-annex is using RequestBodyLBS instead. Unless the documentation is wrong (and I also looked at the http-client source code and the documentation seems accurate), I am doubtful that the chunked transfer encoding is actually being used by git-annex. If eg a protocol dump shows that it is in fact using chunked transfer encoding (ie, contains "Transfer-Encoding: chunked"), that would be grounds to file a bug on the http-client library.
Aah, but.. git-annex is sending an empty file. And the webdav server's check consists of reading 1 byte. Of course there's not a byte to read if an empty file is being sent! So that code you showed is certianly buggy.
I've changed git-annex to send a non-empty file when testing the webdav server to work around this.
hey joey!
thanks, it (kinda) worked :). At least the initialization works now pretty fine. But uploading files does not work as expected. It does upload some data, but does not move the data to the corresponding folder (from 'tmp' to $hash):
In the 'tmp'-folder on the server I can find the file ('SHA256E-s1156230--...'), but this file is not 100% identical to the one I uploaded. Well, it seems that the first byte is missing at least if I compare the files via vimdiff:
As you can see, on the left side (aka 'the uploaded file') the first two hexadecimal values are missing in comparison to the right side (the source), so the first byte is missing.
I guess in the end it is still the same problem, right :)?
As to where the first byte went, it seems rather suggestive that the part of the server's code you pasted earlier reads out
$firstByte
. Perhaps it forgot to preserve that first byte in the file.Which is horrible, but then there's the "Conflict" error. All I can make of this is that the server is probably rejecting the MOVE request for some reason. That might be reasonable if the destination file already existed, but I don't think it does in this case, so who knows.
Only thing I'm sure of is, I never want to entrust this particular webdav server with any of my data!