Package home | Report new bug | New search | Development Roadmap Status: Open | Feedback | All | Closed Since Version 1.0.2

Request #13245 Uploading files is very slow
Submitted: 2008-02-28 14:47 UTC
From: mbaierl Assigned:
Status: No Feedback Package: HTTP_WebDAV_Client (version 1.0.0)
PHP Version: Irrelevant OS:
Roadmaps: (Not assigned)    
Subscription  


 [2008-02-28 14:47 UTC] mbaierl (Michael Baierl)
Description: ------------ Because the standard blocksize of 8k is used and for each 8k block a new HTTP Request is issued uploading is very slow, especially for large files. A smarter way is to collect the 8k packages and only transmit every i.e. 1MB. Changes are needed for the following functions: function stream_write($buffer) { $this->writebuffer .= $buffer; $start = $this->position; $end = $this->position + strlen($buffer); $this->position += strlen($buffer); // should we send the buffer? > 1M if(strlen($this->writebuffer) >= WEBDAV_BUFFERSIZE) $this->stream_flush(); return $end - $start; } function stream_flush() { // do some math $start = $this->writebufferposition; $end = $this->writebufferposition + strlen($this->writebuffer); // create a partial PUT request $req = &new HTTP_Request($this->url); $req->setMethod(HTTP_REQUEST_METHOD_PUT); if (is_string($this->user)) { $req->setAuthCredentials($this->user, @$this->pass); //$req->setBasicAuth($this->user, @$this->pass); } $req->addHeader("Content-Range", "bytes $start-$end/*"); if ($this->locktoken) { $req->addHeader("If", "(<{$this->locktoken}>)"); } $req->addRawPostData($this->writebuffer); // go! go! go! $req->sendRequest(); // check result switch ($req->getResponseCode()) { case 200: case 201: case 204: // clear the writebuffer and update the position $this->writebufferposition = $this->position; $this->writebuffer = ""; return true; default: return false; } } This works like a charm with define('WEBDAV_BUFFERSIZE', 1048576, true);

Comments

 [2008-06-19 06:50 UTC] kawai (Hiroaki Kawai)
I created an HTTP_WebDAV_Client implementation that have local buffer. You can download it from: http://mp.i-revo.jp/user.php/kcvcrlkq/entry/317.html
 [2008-06-19 06:54 UTC] mbaierl (Michael Baierl)
Thanks, but instead of creating duplicate packages this should be integrated into the upstream package. Unfortunately the package owner did not respond yet..... But from looking at the Bug Summary it seems this package is not longer maintained.
 [2008-06-19 07:49 UTC] kawai (Hiroaki Kawai)
Ah, please wait patiently, hholzgra is working. I forgot to note that I added a patch to apply to the CVS version, and I'll donate the patch, too.
 [2011-12-10 07:44 UTC] doconnor (Daniel O'Connor)
Is there any chance of getting this patch redone against the git version + a pull request? clockwerx@clockwerx-desktop:~/pear-svn-git/HTTP_WebDAV_Client$ patch -p1 < patch-download.php\? id\=13245\&patch\=Client_Stream.patch\&revision\=1213858287 can't find file to patch at input line 8 Perhaps you used the wrong -p or --strip option? The text leading up to this was: -------------------------- |Index: Client/Stream.php |================================================ =================== |RCS file: /repository/pear/HTTP_WebDAV_Client/Client/Stream.php,v |retrieving revision 1.15 |diff -u -r1.15 Stream.php |--- Client/Stream.php 12 Jun 2008 10:41:04 -0000 1.15 |+++ Client/Stream.php 19 Jun 2008 06:48:24 -0000 -------------------------- File to patch: HTTP/WebDAV/Client/Stream.php patching file HTTP/WebDAV/Client/Stream.php Hunk #9 FAILED at 351. Hunk #14 succeeded at 678 (offset 2 lines). Hunk #15 succeeded at 713 (offset 2 lines). Hunk #16 succeeded at 747 (offset 2 lines). Hunk #17 succeeded at 788 (offset 2 lines). Hunk #18 succeeded at 869 (offset 2 lines). Hunk #19 succeeded at 910 (offset 2 lines). Hunk #20 succeeded at 963 (offset 2 lines). Hunk #21 succeeded at 981 (offset 2 lines). Hunk #22 succeeded at 1011 (offset 2 lines). 1 out of 22 hunks FAILED -- saving rejects to file HTTP/WebDAV/Client/Stream.php.rej
 [2012-03-25 19:10 UTC] doconnor (Daniel O'Connor)
-Status: Open +Status: No Feedback