Cyberduck Mountain Duck CLI

Changes between Version 1 and Version 2 of help/en/howto/mount/issues/fastcgi

Jan 24, 2018 1:30:45 PM (3 years ago)



  • help/en/howto/mount/issues/fastcgi

    v1 v2  
    1 === The annoying zero byte files issue with Nextcloud and ownCloud ===
     1== The annoying zero byte files issue with Nextcloud and ownCloud ==
     3=== Summary ===
     5Using a client to upload files with chunked transfer encoding to a server with fastcgi/php-fpm enabled can lead to zero byte files.
     7=== Details ===
     9There are basically two options to encode a `PUT` request. You either know the length of the data you want to transfer at the time of starting the request then you can set the HTTP `Content-Length` header appropriately or you don't know the length and thus have to choose a streaming approach using the chunked transfer encoding which does not need a `Content-Length` header at all. A client is free to choose either of the two request types as both are completely fine with the [ HTTP specification].
     11Most clients out there, including web browsers, use the former method and thus do not hit this issue. There are use cases though which make it necessary to transfer data chunked. For example [ Mountain Duck] that implements a virtual file system for accessing your cloud storage online. The write callbacks we get from the OS just include an offset, a buffer length and the buffer itself. Mountain Duck does not know the final file size in advance. From a virtual filesystem perspective the callbacks Mountain Duck get for an upload are as follows.
     141 - CreateFile myFile.txt
     152 - SetAllocationSize myFile.txt, 1024
     163 - WriteFile myFile.txt, offset 0, length 1024, buffer
     174 - SetAllocationSize myFile.txt, 2048
     185 - WriteFile myFile.txt, offset 1024, length 1024, buffer
     196 - CloseFile myFile.txt
     22In step 3 [ Mountain Duck] opens a connection to the remote server, sends a `PUT` request with the http header `Transfer-Encoding: chunked` and streams through all subsequent write callbacks. Finally in step 6 the connection is closed.
     24Since the expected length is missing in the header the streaming characteristic of such requests makes them more difficult to be handled in the components being passed. From our research the issue only exists in environments that use FastCGI to speak to their PHP application. Related bug reports - [ here] and [ here].
     26The nginx developers try to work around this issue by simply buffering the entire incoming stream and forward it through the FastCGI interface as a request with a well-known length. Nginx does request buffering by [ default]. There are several [ options] to adjust the buffering behaviour.
     28Regarding Apache HTTP Server we are not aware of any buffering strategies in [ mod_fcgid] or [ mod_proxy_fcgi / php-fpm] and thus you should avoid using FastCGI. It's recommended to use `mod_php` which is known to handle chunked transfers correctly.
     30=== Clients using chunked transfer encoding ===
     32* Mountain Duck
     33* MacOS Finder
     34* ...
     36=== Resources ===
     38* [ sabre/dav] - the WebDAV library used in NC and OC
     39 * [ Finder]
     40 * [ Zero Byte Files]
swiss made software