I am creating a webdav server to be able to easily add/(re)move files to our backoffice software.
So I am also implementing the PUT command, and that works OK if I use Windows Explorer to create files.
However when I use the Mac OS X Finder (with the help of Transmit, but that makes no difference) to PUT a file to the server, I get no content.
I configured Fiddler as a reverse proxy, and that shows me the following request:
PUT http://localhost:15001/WebDav/test.txt HTTP/1.1
User-Agent: TransmitFSHelper/1.0.2 neon/0.29.3
Connection: TE
TE: trailers
Host: localhost:49416
Content-Length: 0
It does not send any content.
I have read something about ‘trailers’, chunked encoding etcetera, but don’t know wat to respond to the client to get him to send the contents of the file.
When a new file is created (fopen(‘bla’,’w’)) first an empty file will appear on the disk. This is why you’re seeing the initial request with a 0-byte file. After that a program may append to the file, but this will be a separate request.
So treat the 0-byte file as a correct one, and send back 201 Created. You should see a secondary request after that.
however it is true that sometimes clients (such as Finder) will use chunked encoding in the HTTP request. I implemented a webdav server in PHP, and it’s simply not working when using FastCGI and Finder, the server must run on apache with mod_php for it to work.
So if the chunked request fails or succeed depends on your stack, I wouldn’t know with .NET. But at the very least you should be able to see 2 requests going to the server, rather than one. The chunked encoding issue is separate from that.