Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Converting a non seekable stream to a string #123

Closed
mapogolions opened this issue Aug 13, 2019 · 1 comment · Fixed by #127
Closed

Converting a non seekable stream to a string #123

mapogolions opened this issue Aug 13, 2019 · 1 comment · Fixed by #127

Comments

@mapogolions
Copy link
Contributor

mapogolions commented Aug 13, 2019

I looked at the source code of various Stream class implementations. In particular, the __toString method.

I noticed inconsistent behavior when working with non-seekable resources. For instance, a simple pipe - popen('echo 12', 'r').

$fd = popen('echo 12', 'r');
$stream = new Stream($fd);
(string) $stream; // implementation dependent

zend-diactoros && nyholm/psr7
They try to rewind a pipe according to standart, but ignore seek operation and return content, because a pipe is non-seekable.
guzzlehttp/psr7 && slim/psr7
They try to rewind a stream then as result get RuntimeException and return the empty string.
In my opinion, it will be more logical to use the first strategy. What do you thing about it?

@mapogolions mapogolions changed the title Cast to string non-seekable resources Cast to string a non-seekable resources Aug 13, 2019
@mapogolions
Copy link
Contributor Author

I apologize, I will try to return to this problem later. At the moment, it requires too many changes to several repositories.

@mapogolions mapogolions reopened this Aug 24, 2019
@mapogolions mapogolions changed the title Cast to string a non-seekable resources Converting a non seekable stream to a string Aug 24, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant