Skip to content

Commit

Permalink
Merge pull request #61 from ajgarlag/fix-encoding-stream-size
Browse files Browse the repository at this point in the history
Fix encoding stream size
  • Loading branch information
sagikazarmark committed Dec 22, 2016
2 parents 69e4723 + 71e1e0f commit f28c46e
Show file tree
Hide file tree
Showing 10 changed files with 78 additions and 0 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Expand Up @@ -3,6 +3,10 @@

## Unreleased

## Fixed

- FilteredStream::getSize returns null because the contents size is unknown.

### Deprecated

- FilteredStream::getReadFilter The read filter is internal and should never be used by consuming code.
Expand Down
8 changes: 8 additions & 0 deletions spec/Encoding/ChunkStreamSpec.php
Expand Up @@ -39,4 +39,12 @@ function it_chunks_in_multiple()

$this->getContents()->shouldReturn("6\r\nThis i\r\n6\r\ns a st\r\n4\r\nream\r\n0\r\n\r\n");
}

function it_does_not_know_the_content_size()
{
$stream = new MemoryStream('This is a stream');
$this->beConstructedWith($stream, 6);

$this->getSize()->shouldReturn(null);
}
}
9 changes: 9 additions & 0 deletions spec/Encoding/CompressStreamSpec.php
Expand Up @@ -41,4 +41,13 @@ function it_gets_content()
$stream->rewind();
$this->getContents()->shouldReturn(gzcompress('This is a test stream'));
}

function it_does_not_know_the_content_size()
{
$stream = new MemoryStream('This is a test stream');
$this->beConstructedWith($stream);

$stream->rewind();
$this->getSize()->shouldReturn(null);
}
}
8 changes: 8 additions & 0 deletions spec/Encoding/DechunkStreamSpec.php
Expand Up @@ -40,4 +40,12 @@ function it_gets_content()

$this->getContents()->shouldReturn('test');
}

function it_does_not_know_the_content_size()
{
$stream = new MemoryStream("4\r\ntest\r\n4\r\ntest\r\n0\r\n\r\n\0");
$this->beConstructedWith($stream);

$this->getSize()->shouldReturn(null);
}
}
8 changes: 8 additions & 0 deletions spec/Encoding/DecompressStreamSpec.php
Expand Up @@ -41,4 +41,12 @@ function it_gets_content()

$this->getContents()->shouldReturn('This is a test stream');
}

function it_does_not_know_the_content_size()
{
$stream = new MemoryStream(gzcompress('This is a test stream'));
$this->beConstructedWith($stream);

$this->getSize()->shouldReturn(null);
}
}
8 changes: 8 additions & 0 deletions spec/Encoding/DeflateStreamSpec.php
Expand Up @@ -36,4 +36,12 @@ function it_gets_content()
$stream->rewind();
$this->getContents()->shouldReturn(gzdeflate('This is a test stream'));
}

function it_does_not_know_the_content_size()
{
$stream = new MemoryStream('This stream is a test stream');
$this->beConstructedWith($stream);

$this->getSize()->shouldReturn(null);
}
}
8 changes: 8 additions & 0 deletions spec/Encoding/GzipDecodeStreamSpec.php
Expand Up @@ -41,4 +41,12 @@ function it_gets_content()

$this->getContents()->shouldReturn('This is a test stream');
}

function it_does_not_know_the_content_size()
{
$stream = new MemoryStream(gzencode('This is a test stream'));
$this->beConstructedWith($stream);

$this->getSize()->shouldReturn(null);
}
}
9 changes: 9 additions & 0 deletions spec/Encoding/GzipEncodeStreamSpec.php
Expand Up @@ -41,4 +41,13 @@ function it_gets_content()
$stream->rewind();
$this->getContents()->shouldReturn(gzencode('This is a test stream'));
}

function it_does_not_know_the_content_size()
{
$stream = new MemoryStream('This is a test stream');
$this->beConstructedWith($stream);

$stream->rewind();
$this->getSize()->shouldReturn(null);
}
}
8 changes: 8 additions & 0 deletions spec/Encoding/InflateStreamSpec.php
Expand Up @@ -36,4 +36,12 @@ function it_gets_content()

$this->getContents()->shouldReturn('This is a test stream');
}

function it_does_not_know_the_content_size()
{
$stream = new MemoryStream(gzdeflate('This stream is a test stream'));
$this->beConstructedWith($stream);

$this->getSize()->shouldReturn(null);
}
}
8 changes: 8 additions & 0 deletions src/Encoding/FilteredStream.php
Expand Up @@ -138,6 +138,14 @@ public function getContents()
return $buffer;
}

/**
* {@inheritdoc}
*/
public function getSize()
{
return;
}

/**
* {@inheritdoc}
*/
Expand Down

0 comments on commit f28c46e

Please sign in to comment.