[Pkg-owncloud-commits] [php-sabredav] 08/28: Fixed bug. Upgraded unittests.
David Prévot
taffit at moszumanska.debian.org
Sun Mar 13 17:59:08 UTC 2016
This is an automated email from the git hooks/post-receive script.
taffit pushed a commit to branch master
in repository php-sabredav.
commit c8d9004554e23e1393ab0613d00780dbe6cda366
Author: Evert Pot <me at evertpot.com>
Date: Tue Mar 8 17:13:33 2016 -0500
Fixed bug. Upgraded unittests.
---
lib/DAV/CorePlugin.php | 2 +-
tests/Sabre/DAV/ServerRangeTest.php | 130 +++++++++++++++++-------------------
2 files changed, 64 insertions(+), 68 deletions(-)
diff --git a/lib/DAV/CorePlugin.php b/lib/DAV/CorePlugin.php
index 046e395..4cb1370 100644
--- a/lib/DAV/CorePlugin.php
+++ b/lib/DAV/CorePlugin.php
@@ -172,7 +172,7 @@ class CorePlugin extends ServerPlugin {
// Streams may advertise themselves as seekable, but still not
// actually allow fseek. We'll manually go forward in the stream
// if fseek failed.
- if (!stream_get_meta_data($body)['seekable'] || fseek($body, $start, SEEK_SET) === 0) {
+ if (!stream_get_meta_data($body)['seekable'] || fseek($body, $start, SEEK_SET) === -1) {
$consumeBlock = 8192;
for ($consumed = 0; $start - $consumed > 0;){
if (feof($body)) throw new Exception\RequestedRangeNotSatisfiable('The start offset (' . $start . ') exceeded the size of the entity (' . $consumed . ')');
diff --git a/tests/Sabre/DAV/ServerRangeTest.php b/tests/Sabre/DAV/ServerRangeTest.php
index 5dfd5ae..8253fc9 100644
--- a/tests/Sabre/DAV/ServerRangeTest.php
+++ b/tests/Sabre/DAV/ServerRangeTest.php
@@ -15,15 +15,13 @@ class ServerRangeTest extends AbstractServer{
function testRange() {
- $serverVars = [
- 'REQUEST_URI' => '/test.txt',
- 'REQUEST_METHOD' => 'GET',
- 'HTTP_RANGE' => 'bytes=2-5',
- ];
+ $request = new HTTP\Request(
+ 'GET',
+ '/test.txt',
+ ['Range' => 'Bytes=2-5']
+ );
$filename = SABRE_TEMPDIR . '/test.txt';
-
- $request = HTTP\Sapi::createFromServerArray($serverVars);
- $this->server->httpRequest = ($request);
+ $this->server->httpRequest = $request;
$this->server->exec();
$this->assertEquals([
@@ -47,15 +45,14 @@ class ServerRangeTest extends AbstractServer{
*/
function testStartRange() {
- $serverVars = [
- 'REQUEST_URI' => '/test.txt',
- 'REQUEST_METHOD' => 'GET',
- 'HTTP_RANGE' => 'bytes=2-',
- ];
+ $request = new HTTP\Request(
+ 'GET',
+ '/test.txt',
+ ['Range' => 'bytes=2-']
+ );
$filename = SABRE_TEMPDIR . '/test.txt';
- $request = HTTP\Sapi::createFromServerArray($serverVars);
- $this->server->httpRequest = ($request);
+ $this->server->httpRequest = $request;
$this->server->exec();
$this->assertEquals([
@@ -79,15 +76,14 @@ class ServerRangeTest extends AbstractServer{
*/
function testEndRange() {
- $serverVars = [
- 'REQUEST_URI' => '/test.txt',
- 'REQUEST_METHOD' => 'GET',
- 'HTTP_RANGE' => 'bytes=-8',
- ];
+ $request = new HTTP\Request(
+ 'GET',
+ '/test.txt',
+ ['Range' => 'bytes=-8']
+ );
$filename = SABRE_TEMPDIR . '/test.txt';
- $request = HTTP\Sapi::createFromServerArray($serverVars);
- $this->server->httpRequest = ($request);
+ $this->server->httpRequest = $request;
$this->server->exec();
$this->assertEquals([
@@ -111,14 +107,13 @@ class ServerRangeTest extends AbstractServer{
*/
function testTooHighRange() {
- $serverVars = [
- 'REQUEST_URI' => '/test.txt',
- 'REQUEST_METHOD' => 'GET',
- 'HTTP_RANGE' => 'bytes=100-200',
- ];
+ $request = new HTTP\Request(
+ 'GET',
+ '/test.txt',
+ ['Range' => 'bytes=100-200']
+ );
- $request = HTTP\Sapi::createFromServerArray($serverVars);
- $this->server->httpRequest = ($request);
+ $this->server->httpRequest = $request;
$this->server->exec();
$this->assertEquals(416, $this->response->status);
@@ -130,14 +125,13 @@ class ServerRangeTest extends AbstractServer{
*/
function testCrazyRange() {
- $serverVars = [
- 'REQUEST_URI' => '/test.txt',
- 'REQUEST_METHOD' => 'GET',
- 'HTTP_RANGE' => 'bytes=8-4',
- ];
+ $request = new HTTP\Request(
+ 'GET',
+ '/test.txt',
+ ['Range' => 'bytes=8-4']
+ );
- $request = HTTP\Sapi::createFromServerArray($serverVars);
- $this->server->httpRequest = ($request);
+ $this->server->httpRequest = $request;
$this->server->exec();
$this->assertEquals(416, $this->response->status);
@@ -151,16 +145,14 @@ class ServerRangeTest extends AbstractServer{
$node = $this->server->tree->getNodeForPath('test.txt');
- $serverVars = [
- 'REQUEST_URI' => '/test.txt',
- 'REQUEST_METHOD' => 'GET',
- 'HTTP_RANGE' => 'bytes=2-5',
- 'HTTP_IF_RANGE' => $node->getETag(),
- ];
+ $request = new HTTP\Request(
+ 'GET',
+ '/test.txt',
+ ['Range' => 'bytes=2-5']
+ );
$filename = SABRE_TEMPDIR . '/test.txt';
- $request = HTTP\Sapi::createFromServerArray($serverVars);
- $this->server->httpRequest = ($request);
+ $this->server->httpRequest = $request;
$this->server->exec();
$this->assertEquals([
@@ -186,16 +178,17 @@ class ServerRangeTest extends AbstractServer{
$node = $this->server->tree->getNodeForPath('test.txt');
- $serverVars = [
- 'REQUEST_URI' => '/test.txt',
- 'REQUEST_METHOD' => 'GET',
- 'HTTP_RANGE' => 'bytes=2-5',
- 'HTTP_IF_RANGE' => $node->getETag() . 'blabla',
- ];
+ $request = new HTTP\Request(
+ 'GET',
+ '/test.txt',
+ [
+ 'Range' => 'bytes=2-5',
+ 'If-Range' => $node->getEtag() . 'blabla'
+ ]
+ );
$filename = SABRE_TEMPDIR . '/test.txt';
- $request = HTTP\Sapi::createFromServerArray($serverVars);
- $this->server->httpRequest = ($request);
+ $this->server->httpRequest = $request;
$this->server->exec();
$this->assertEquals([
@@ -220,15 +213,16 @@ class ServerRangeTest extends AbstractServer{
$node = $this->server->tree->getNodeForPath('test.txt');
- $serverVars = [
- 'REQUEST_URI' => '/test.txt',
- 'REQUEST_METHOD' => 'GET',
- 'HTTP_RANGE' => 'bytes=2-5',
- 'HTTP_IF_RANGE' => 'tomorrow',
- ];
+ $request = new HTTP\Request(
+ 'GET',
+ '/test.txt',
+ [
+ 'Range' => 'bytes=2-5',
+ 'If-Range' => 'tomorrow',
+ ]
+ );
$filename = SABRE_TEMPDIR . '/test.txt';
- $request = HTTP\Sapi::createFromServerArray($serverVars);
$this->server->httpRequest = ($request);
$this->server->exec();
@@ -255,16 +249,18 @@ class ServerRangeTest extends AbstractServer{
$node = $this->server->tree->getNodeForPath('test.txt');
- $serverVars = [
- 'REQUEST_URI' => '/test.txt',
- 'REQUEST_METHOD' => 'GET',
- 'HTTP_RANGE' => 'bytes=2-5',
- 'HTTP_IF_RANGE' => '-2 years',
- ];
+ $request = new HTTP\Request(
+ 'GET',
+ '/test.txt',
+ [
+ 'Range' => 'bytes=2-5',
+ 'If-Range' => '-2 years',
+ ]
+ );
+
$filename = SABRE_TEMPDIR . '/test.txt';
- $request = HTTP\Sapi::createFromServerArray($serverVars);
- $this->server->httpRequest = ($request);
+ $this->server->httpRequest = $request;
$this->server->exec();
$this->assertEquals([
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-php/php-sabredav.git
More information about the Pkg-owncloud-commits
mailing list