<html><head><title>501 Not Implemented</title>
</head><body><h2>501 Not Implemented</h2></body></html>

What I'm trying to do is recursively upload a file tree from computer->phone without running a samba server on the computer.  Correct me if I'm wrong, but the phone's WebDAV server *should* allow this, in conjunction with cadaver or nautilus/gvfsd-dav or wdfs.  The web-interface only allows single-file upload. 

Could not open collection:
Could not read response body: Connection reset by peer

Cadaver, wdfs and davfs2 all use libneon, and this error happens when reading from the socket returns <0, in `read_response_block`, caused by totalcommander sending a RST packet rather than FIN/ACK (is it possible you are missing a shutdown()?).  Cadaver's `--tolerant` options is handled afterwards, which explains why it has no effect.  The cadaver codepath is `ne_options` from neon, which determines server capabilities using OPTIONS. 

Reading from socket returning <0 means that the conmnection is dead.  TC doesn't just drop the connection, so the server must have dropped it.  Do you see any errors in the server log?_________________Author of Total Commander
http://www.ghisler.com

Yes, "Send via WiFi" runs a local WebDAV server.  Have a look at the thread title! 

Apparently this "cadavar" client is sending this OPTIONS command, which the server doesn't understand.  Therefore my server reports error 501 Not Implemented.  The client should be able to handle that, and continue the operation without OPTIONS command._________________Author of Total Commander
http://www.ghisler.com

TC does send a 501 message, but then abruptly closes the socket by sending RST.  So the client (in this case cadaver but also every client available on linux), in the read loop, reads the 501, tries to read more from the now-closed socket and gets a -1 return code (rather than 0 if FIN/ACK had been sent), which causes the client to exit.  So the client never gets the opportunity to process/handle the 501 message. 

TC closes the connection gracefully - and it includes a header "Connection: close" with all replies, since it doesn't currently support multiple commands in one connection._________________Author of Total Commander
http://www.ghisler.com

/* Reads a block of the response into BUFFER, which is of size
* *BUFLEN.  Returns zero on success or non-zero on error.  On
* success, *BUFLEN is updated to be the number of bytes read into
* BUFFER (which will be 0 to indicate the end of the repsonse).  On
* error, the connection is closed and the session error string is
* set. */ 
static int read_response_block(ne_request *req, struct ne_response *resp,
char *buffer, size_t *buflen)
{
ne_socket *const sock = req->session->socket;
size_t willread;
ssize_t readlen;

The cadaver client initializes the connection by calling `open_connection` (the is the cadaver client) -> `ne_options` (just a wrapper) -> `ne_options2` -> `ne_request_dispatch` -> `ne_discard_response` -> `ne_read_response_block` -> `read_response_block`.  The last function `read_response_block` behaves exactly like 'man read(3)': returns <0 in error or reads a chunk of data, possibly less than requested.  The function `ne_discard_response` loops until all the data is read and returns NE_OK, or NE_ERROR if there was an error in `read_response_block`.  This status is bubbles back to `ne_options2` which re-interprets NE_OK with a non-200 class HTTP response code as NE_ERROR.  The cadaver client in `open_connection` requires NE_OK (i.e. HTTP 200) in order to continue, so OPTIONS must be supported (`ne_options` only creates an OPTIONS request).  The `--tolerant` option is only applied by cadaver (via the `set_path` function) upon receiving NE_OK. 

While cadaver won't work with any servers not supporting OPTIONS, Total Commander closes the connection by sending RST rather than FIN/ACK.  Even though the end-result is the same, it shouldn't happen:

I then added PROPFIND and OPTIONS support to webdav via the nginx-dav-ext-module module [1].  The case for `NGX_HTTP_OPTIONS` seems relatively simple, so it should be a good guide to implementing OPTIONS in Total Commander.  Unfortunately this nginx module requires both OPTIONS and PROPFIND; only enabling OPTIONS in 'nginx.conf' via `dav_ext_methods OPTIONS;` breaks the WebDav implementation.  The server claims to support PROPFIND (even though it is disabled), so cadaver receives an HTTP 405 when it sends a PROPFIND request, leading to this message:

Code:

Ignored error: /dav/source/ not WebDAV-enabled:
405 Not Allowed

In any case I've attached the wireshark trace and cadaver log from cadaver interacting with a server supporting OPTIONS and PROPFIND: