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

Fix incompatibilities between Unseekable streams and SapiStreamEmitter #200

Merged
merged 2 commits into from
Sep 7, 2016

Conversation

markstory
Copy link
Contributor

Make SapiStreamEmitter work with streams that don't support seek operations. This allows CallbackStream responses to be combined with SapiStreamEmitter.

Refs #199

If a stream does not support seek, we have to rely on __toString()
to access the stream's contents. If a stream cannot be rewound, it
likely can't be incrementally read either.

Refs zendframework#199
While it would be preferrable to seek around the stream, some streams
cannot be looked at. In these cases the best effort we can have is to
get the entire stream and slice out the requested byte range.

Refs zendframework#199
@markstory
Copy link
Contributor Author

Looks like your PHPCS checks are failing. Should I fix those up?

@@ -72,10 +76,17 @@ private function emitBody(ResponseInterface $response, $maxBufferLength)
*/
private function emitBodyRange(array $range, ResponseInterface $response, $maxBufferLength)
{
list($unit, $first, $last, $lenght) = $range;
list($unit, $first, $last, $length) = $range;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this change already at #186

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, I didn't see that.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No worries; I merged in order, and since they were the exact same change, it presented no conflict during merge. 😄

@samsonasik
Copy link
Contributor

@markstory I created PR #201 for the cs fix

@weierophinney weierophinney added this to the 1.3.6 milestone Sep 7, 2016
@weierophinney weierophinney self-assigned this Sep 7, 2016
weierophinney added a commit that referenced this pull request Sep 7, 2016
Fix incompatibilities between Unseekable streams and SapiStreamEmitter
weierophinney added a commit that referenced this pull request Sep 7, 2016
@weierophinney weierophinney merged commit 92b1e34 into zendframework:master Sep 7, 2016
weierophinney added a commit that referenced this pull request Sep 7, 2016
weierophinney added a commit that referenced this pull request Sep 7, 2016
@weierophinney
Copy link
Member

Thanks for this, @markstory!

@markstory
Copy link
Contributor Author

Thanks for the quick merge @weierophinney 💃

weierophinney added a commit that referenced this pull request Sep 7, 2016
Order of operations was critical here; always check to see if the body
is seekable before attempting to rewind it.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants