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

Commit dacb3df

Browse files
committed
Merge branch 'hotfix/222'
Close #222
2 parents 5e72635 + c76b9b1 commit dacb3df

File tree

3 files changed

+7
-2
lines changed

3 files changed

+7
-2
lines changed

CHANGELOG.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,11 @@ All notable changes to this project will be documented in this file, in reverse
1818

1919
### Fixed
2020

21-
- Nothing.
21+
- [#222](https://github.com/zendframework/zend-diactoros/pull/222) fixes the
22+
`SapiStreamEmitter`'s handling of the `Content-Range` header to properly only
23+
emit a range of bytes if the header value is in the form `bytes {first-last}/length`.
24+
This allows using other range units, such as `items`, without incorrectly
25+
emitting truncated content.
2226

2327
## 1.3.7 - 2016-10-11
2428

src/Response/SapiStreamEmitter.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ public function emit(ResponseInterface $response, $maxBufferLength = 8192)
4040

4141
$range = $this->parseContentRange($response->getHeaderLine('Content-Range'));
4242

43-
if (is_array($range)) {
43+
if (is_array($range) && $range[0] === 'bytes') {
4444
$this->emitBodyRange($range, $response, $maxBufferLength);
4545
return;
4646
}

test/Response/SapiStreamEmitterTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ public function contentRangeProvider()
6363
return [
6464
['bytes 0-2/*', 'Hello world', 'Hel'],
6565
['bytes 3-6/*', 'Hello world', 'lo w'],
66+
['items 0-0/1', 'Hello world', 'Hello world'],
6667
];
6768
}
6869

0 commit comments

Comments
 (0)