php-http / message

HTTP Message related tools
http://php-http.org
MIT License
1.29k stars 41 forks source link

Add buffered stream #52

Closed joelwurtz closed 8 years ago

joelwurtz commented 8 years ago
Q A
Bug fix? yes
New feature? yes
BC breaks? no
Deprecations? no
Related tickets mentioned in #46, replace #49
Documentation
License MIT

This is a replacement for the MemoryCloner, this allow to decorate a not seekable stream with a seekable one.

In order to do that it buffer the underlying stream into a php://temp resource by default (but can also be fully buffered into memory).

It never reads the underlying stream, until it has been tell to do so.

Once this is merged i will add a EnsureSeekableStreamPlugin, which decorates the request body and the response body with this one if the existing stream is not seekable, so we would be able to get the stream content (format) even for not seekable stream (only if user want it).

joelwurtz commented 8 years ago

Is it ok to merge ?

dbu commented 8 years ago

looks good to me. @Nyholm @sagikazarmark do you agree?

sagikazarmark commented 8 years ago

AFAIK there are some PSR7 compliance test suits out there. Maybe we should use them to test PSR7 implementations. If they are not good enough, maybe we could write one? Apart from that, LGTM.

Nyholm commented 8 years ago

👍

dbu commented 8 years ago

more testing is always good, but lets not hold up merging. @joelwurtz if you have time to check out the idea from mark, that would be great to detect issues before we release.

joelwurtz commented 8 years ago

I only found https://github.com/Maks3w/Psr7Assertions but this does not test stream

sagikazarmark commented 8 years ago

I was once thinking about writting a PSR7 tester lib which accepts message factories to create messages/streams so that it can handle specific data and other options. The other possibility is to have an abstract method which returns a PSR7 object instance and that can be used since its immutable, although there would be some drawbacks like streams are noz immutable, etc.