Skip to content

Commit

Permalink
Merge a5e908a into 2120bdd
Browse files Browse the repository at this point in the history
  • Loading branch information
ostrolucky committed Mar 23, 2019
2 parents 2120bdd + a5e908a commit 5a40af1
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 0 deletions.
5 changes: 5 additions & 0 deletions lib/ResourceInputStream.php
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,11 @@ public function getResource()
return $this->resource;
}

public function setChunkSize(int $chunkSize)
{
$this->chunkSize = $chunkSize;
}

/**
* References the read watcher, so the loop keeps running in case there's an active read.
*
Expand Down
5 changes: 5 additions & 0 deletions lib/ResourceOutputStream.php
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,11 @@ public function getResource()
return $this->resource;
}

public function setChunkSize(int $chunkSize)
{
$this->chunkSize = $chunkSize;
}

public function __destruct()
{
if ($this->resource !== null) {
Expand Down
15 changes: 15 additions & 0 deletions test/ResourceStreamTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -274,4 +274,19 @@ public function testIssue47()
$this->assertStringEqualsFile(__FILE__, $buffer);
});
}

public function testSetChunkSize()
{
Loop::run(function () {
list($a, $b) = $this->getStreamPair();
$a->setChunkSize(1);
$b->setChunkSize(1);

$this->assertSame(3, yield $a->write('foo'));
$this->assertSame('f', yield $b->read());

$b->setChunkSize(3);
$this->assertSame('oo', yield $b->read());
});
}
}

0 comments on commit 5a40af1

Please sign in to comment.