Req #13245 [Opn->NoF]: Uploading files is very slow
| From: | daniel dot oconnor at gmail dot com | Date: | Sun, 25 Mar 2012 14:10:10 +0000 |
| Subject: | Req #13245 [Opn->NoF]: Uploading files is very slow | ||
| References: | 1 | Groups: | php.pear.bugs |
| Request: | Send a blank email to pear-bugs+get-8436@lists.php.net to get a copy of this message | ||
Edit report at https://pear.php.net/bugs/bug.php?id=13245&edit=1
ID: 13245
Updated by: daniel.oconnor@gmail.com
Reported By: mail at mbaierl dot com
Summary: Uploading files is very slow
-Status: Open
+Status: No Feedback
Type: Feature/Change Request
Package: HTTP_WebDAV_Client
Package Version: 1.0.0
PHP Version: Irrelevant
Roadmap Versions:
New Comment:
-Status: Open
+Status: No Feedback
Previous Comments:
------------------------------------------------------------------------
[2011-12-10 02:44:20] doconnor
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
------------------------------------------------------------------------
[2008-06-19 03:49:05] 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.
------------------------------------------------------------------------
[2008-06-19 02:54:20] mbaierl
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 02:50:58] 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-02-28 09:47:50] mbaierl
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);
------------------------------------------------------------------------
--
Edit this bug report at https://pear.php.net/bugs/bug.php?id=13245&edit=1