Skip to content
This repository was archived by the owner on Jan 29, 2020. It is now read-only.

Commit 126f2e4

Browse files
committed
Merge branch 'hotfix/79'
Close #79 Fixes #78
2 parents 43a350a + efa2db4 commit 126f2e4

File tree

3 files changed

+12
-1
lines changed

3 files changed

+12
-1
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@ All notable changes to this project will be documented in this file, in reverse
2121
- [#71](https://github.com/zendframework/zend-diactoros/pull/71) fixes the
2222
docblock of the `JsonResponse` constructor to typehint the `$data` argument
2323
as `mixed`.
24+
- [#73](https://github.com/zendframework/zend-diactoros/pull/73) changes the
25+
behavior in `Request` such that if it marshals a stream during instantiation,
26+
the stream is marked as writeable (specifically, mode `wb+`).
2427

2528
## 1.1.2 - 2015-07-12
2629

src/RequestTrait.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ private function initialize($uri = null, $method = null, $body = 'php://memory',
8282

8383
$this->method = $method ?: '';
8484
$this->uri = $uri ?: new Uri();
85-
$this->stream = ($body instanceof StreamInterface) ? $body : new Stream($body, 'r');
85+
$this->stream = ($body instanceof StreamInterface) ? $body : new Stream($body, 'wb+');
8686

8787
list($this->headerNames, $headers) = $this->filterHeaders($headers);
8888
$this->assertHeaders($headers);

test/RequestTest.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,14 @@ public function testConstructorCanAcceptAllMessageParts()
9292
}
9393
}
9494

95+
public function testDefaultStreamIsWritable()
96+
{
97+
$request = new Request();
98+
$request->getBody()->write("test");
99+
100+
$this->assertSame("test", (string)$request->getBody());
101+
}
102+
95103
public function invalidRequestUri()
96104
{
97105
return [

0 commit comments

Comments
 (0)