27        $this->server->createFile(
'files/test.txt', 
'Test contents');
 
   30            new DateTime(
'@' . $this->server->tree->getNodeForPath(
'files/test.txt')->getLastModified())
 
   33        $stream = popen(
'echo "Test contents"', 
'r');
 
   38        $streamingFile->setSize(12);
 
   39        $this->server->tree->getNodeForPath(
'files')->addNode($streamingFile);
 
   45        $request = 
new HTTP\Request(
'GET', 
'/files/test.txt', [
'Range' => 
'bytes=2-5']);
 
   50            'Content-Type'    => [
'application/octet-stream'],
 
   51            'Content-Length'  => [4],
 
   52            'Content-Range'   => [
'bytes 2-5/13'],
 
   53            'ETag'            => [
'"' . md5(
'Test contents') . 
'"'],
 
   54            'Last-Modified'   => [$this->lastModified],
 
   58        $this->assertEquals(206, 
$response->getStatus());
 
   59        $this->assertEquals(
'st c', 
$response->getBodyAsString());
 
   68        $request = 
new HTTP\Request(
'GET', 
'/files/test.txt', [
'Range' => 
'bytes=2-']);
 
   73            'Content-Type'    => [
'application/octet-stream'],
 
   74            'Content-Length'  => [11],
 
   75            'Content-Range'   => [
'bytes 2-12/13'],
 
   76            'ETag'            => [
'"' . md5(
'Test contents') . 
'"'],
 
   77            'Last-Modified'   => [$this->lastModified],
 
   82        $this->assertEquals(206, 
$response->getStatus());
 
   83        $this->assertEquals(
'st contents', 
$response->getBodyAsString());
 
   92        $request = 
new HTTP\Request(
'GET', 
'/files/test.txt', [
'Range' => 
'bytes=-8']);
 
   97            'Content-Type'    => [
'application/octet-stream'],
 
   98            'Content-Length'  => [8],
 
   99            'Content-Range'   => [
'bytes 5-12/13'],
 
  100            'ETag'            => [
'"' . md5(
'Test contents') . 
'"'],
 
  101            'Last-Modified'   => [$this->lastModified],
 
  106        $this->assertEquals(206, 
$response->getStatus());
 
  107        $this->assertEquals(
'contents', 
$response->getBodyAsString());
 
  116        $request = 
new HTTP\Request(
'GET', 
'/files/test.txt', [
'Range' => 
'bytes=100-200']);
 
  119        $this->assertEquals(416, 
$response->getStatus());
 
  128        $request = 
new HTTP\Request(
'GET', 
'/files/test.txt', [
'Range' => 
'bytes=8-4']);
 
  131        $this->assertEquals(416, 
$response->getStatus());
 
  137        $request = 
new HTTP\Request(
'GET', 
'/files/no-seeking.txt', [
'Range' => 
'bytes=2-5']);
 
  141        $this->assertEquals([
 
  143            'Content-Type'    => [
'application/octet-stream'],
 
  144            'Content-Length'  => [4],
 
  145            'Content-Range'   => [
'bytes 2-5/12'],
 
  147            'Last-Modified' => [$this->lastModified],
 
  152        $this->assertEquals(
'st c', 
$response->getBodyAsString());
 
  161        $request = 
new HTTP\Request(
'GET', 
'/files/test.txt', [
 
  162            'Range'    => 
'bytes=2-5',
 
  163            'If-Range' => 
'"' . md5(
'Test contents') . 
'"',
 
  167        $this->assertEquals([
 
  169            'Content-Type'    => [
'application/octet-stream'],
 
  170            'Content-Length'  => [4],
 
  171            'Content-Range'   => [
'bytes 2-5/13'],
 
  172            'ETag'            => [
'"' . md5(
'Test contents') . 
'"'],
 
  173            'Last-Modified'   => [$this->lastModified],
 
  178        $this->assertEquals(206, 
$response->getStatus());
 
  179        $this->assertEquals(
'st c', 
$response->getBodyAsString());
 
  188        $request = 
new HTTP\Request(
'GET', 
'/files/test.txt', [
 
  189            'Range'    => 
'bytes=2-5',
 
  190            'If-Range' => 
'"foobar"',
 
  194        $this->assertEquals([
 
  196            'Content-Type'    => [
'application/octet-stream'],
 
  197            'Content-Length'  => [13],
 
  198            'ETag'            => [
'"' . md5(
'Test contents') . 
'"'],
 
  199            'Last-Modified'   => [$this->lastModified],
 
  204        $this->assertEquals(200, 
$response->getStatus());
 
  205        $this->assertEquals(
'Test contents', 
$response->getBodyAsString());
 
  214        $request = 
new HTTP\Request(
'GET', 
'/files/test.txt', [
 
  215            'Range'    => 
'bytes=2-5',
 
  216            'If-Range' => 
'tomorrow',
 
  220        $this->assertEquals([
 
  222            'Content-Type'    => [
'application/octet-stream'],
 
  223            'Content-Length'  => [4],
 
  224            'Content-Range'   => [
'bytes 2-5/13'],
 
  225            'ETag'            => [
'"' . md5(
'Test contents') . 
'"'],
 
  226            'Last-Modified'   => [$this->lastModified],
 
  231        $this->assertEquals(206, 
$response->getStatus());
 
  232        $this->assertEquals(
'st c', 
$response->getBodyAsString());
 
  241        $request = 
new HTTP\Request(
'GET', 
'/files/test.txt', [
 
  242            'Range'    => 
'bytes=2-5',
 
  243            'If-Range' => 
'-2 years',
 
  247        $this->assertEquals([
 
  249            'Content-Type'    => [
'application/octet-stream'],
 
  250            'Content-Length'  => [13],
 
  251            'ETag'            => [
'"' . md5(
'Test contents') . 
'"'],
 
  252            'Last-Modified'   => [$this->lastModified],
 
  257        $this->assertEquals(200, 
$response->getStatus());
 
  258        $this->assertEquals(
'Test contents', 
$response->getBodyAsString());
 
foreach($paths as $path) $request
An exception for terminatinating execution or to throw for unit testing.
This class may be used as a basis for other webdav-related unittests.
request($request, $expectedStatus=null)
Makes a request, and returns a response object.
Mock Streaming File File.
This file tests HTTP requests that use the Range: header.
testIfRangeModificationDate()
@depends testIfRangeEtag
testIfRangeModificationDateModified()
@depends testIfRangeModificationDate
testEndRange()
@depends testRange
testIfRangeEtagIncorrect()
@depends testIfRangeEtag
testIfRangeEtag()
@depends testRange
testTooHighRange()
@depends testRange
testStartRange()
@depends testRange
$lastModified
We need this string a lot.
testCrazyRange()
@depends testRange
const VERSION
Full version number.
static toHTTPDate(\DateTime $dateTime)
Transforms a DateTime object to HTTP's most common date format.
$stream
PHP stream implementation.