Skip to content

Commit e9c1041

Browse files
committed
Return stream when body is empty
1 parent 5265147 commit e9c1041

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

src/StreamFactory/DiactorosStreamFactory.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,12 @@ public function createStream($body = null)
2424
} else {
2525
$stream = new Stream('php://memory', 'rw');
2626

27-
if (null !== $body || '' !== $body) {
28-
$stream->write((string) $body);
27+
if (null === $body || '' === $body) {
28+
return $stream;
2929
}
3030

31+
$stream->write((string) $body);
32+
3133
$body = $stream;
3234
}
3335
}

src/StreamFactory/SlimStreamFactory.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,11 @@ public function createStream($body = null)
2828
$resource = fopen('php://memory', 'r+');
2929
$stream = new Stream($resource);
3030

31-
if (null !== $body || '' !== $body) {
32-
$stream->write((string) $body);
31+
if (null === $body || '' === $body) {
32+
return $stream;
3333
}
34+
35+
$stream->write((string) $body);
3436
}
3537

3638
$stream->rewind();

0 commit comments

Comments
 (0)