# |
Mar 2nd 2018, 14:28 |
admad |
ionas: $response = (new Client)->get($url); $cacheThis = (string)$response->getBody(); |
# |
Mar 2nd 2018, 14:28 |
hmic |
still, i'm not talking clients :p |
# |
Mar 2nd 2018, 14:28 |
inoas |
Adapter for sending requests. Defaults to Cake\Http\Client\Adapter\Stream |
# |
Mar 2nd 2018, 14:28 |
inoas |
for http clients |
# |
Mar 2nd 2018, 14:27 |
inoas |
it is |
# |
Mar 2nd 2018, 14:27 |
hmic |
and the streaming response is not the default one anyways |
# |
Mar 2nd 2018, 14:27 |
inoas |
$responses = $this->_adapter->send($request, $options); |
# |
Mar 2nd 2018, 14:26 |
hmic |
i'm not talking of requests, but responses anyways |
# |
Mar 2nd 2018, 14:26 |
inoas |
eh no |
# |
Mar 2nd 2018, 14:26 |
hmic |
i suppose still the same idomatic problem: you can't have the "whole" *stream* at once. |
# |
Mar 2nd 2018, 14:26 |
inoas |
which is Psr\Http\Message\RequestInterface |
# |
Mar 2nd 2018, 14:26 |
inoas |
which returns \Cake\Http\Client\Request |
# |
Mar 2nd 2018, 14:25 |
hmic |
*doh* |
# |
Mar 2nd 2018, 14:25 |
inoas |
I am talking about Cake\Http\Client |
# |
Mar 2nd 2018, 14:25 |
hmic |
*not* consumes |
# |
Mar 2nd 2018, 14:25 |
hmic |
client? you are talking about a response! this is a serverResponse cake creates |
# |
Mar 2nd 2018, 14:24 |
inoas |
admad are you sure that that StreamInterface is compatible with Cake\Http\Client\Adapter\Stream ? seems to implement different methods |
# |
Mar 2nd 2018, 14:24 |
inoas |
or a streaming one which passes down a write-target instead of returning the streaming data to the outer functions then to the output buffer |
# |
Mar 2nd 2018, 14:23 |
inoas |
so that i can build a non-streaming adapter |
# |
Mar 2nd 2018, 14:23 |
inoas |
I just need an interface for the 'adapter' |
# |
Mar 2nd 2018, 14:23 |
inoas |
CakePHP's Client has 'adapter' => 'Cake\Http\Client\Adapter\Stream', |
# |
Mar 2nd 2018, 14:22 |
hmic |
it is. just not with a streamed response, as per the definition. |
# |
Mar 2nd 2018, 14:22 |
inoas |
so I want to feed the stream one by one into say redis or a file cache |
# |
Mar 2nd 2018, 14:22 |
inoas |
that is a performance optimization and as HTTP GET is idempotent I should be technically allowed to do so |
# |
Mar 2nd 2018, 14:22 |
hmic |
what do you use the stream for? - things that are so big that they would exhaust the php memory, if not streamed! |
# |
Mar 2nd 2018, 14:21 |
inoas |
I fire HTTP GET requests and want to locally cache the response |
# |
Mar 2nd 2018, 14:21 |
inoas |
again I don't care what I should not |
# |
Mar 2nd 2018, 14:21 |
hmic |
as it's a stream |
# |
Mar 2nd 2018, 14:21 |
hmic |
and you should not |
# |
Mar 2nd 2018, 14:21 |
inoas |
otherwise I cannot cache the response |
# |
Mar 2nd 2018, 14:21 |
inoas |
yes but I need that, the stream to get all data and close |
# |
Mar 2nd 2018, 14:16 |
hmic |
thats the whole idea |
# |
Mar 2nd 2018, 14:16 |
hmic |
a stream does not have a "complete" response at any given time |
# |
Mar 2nd 2018, 14:14 |
inoas |
otherwise I cannot cache it locally into whatever (files, redis, apcu) |
# |
Mar 2nd 2018, 14:14 |
inoas |
as I said I don't want a stream, just the complete response body |
# |
Mar 2nd 2018, 14:13 |
inoas |
admad so the interface is just missing from the class declaration head? |
# |
Mar 2nd 2018, 13:57 |
admad |
https://github.com/zendframework/zend-diactoros/blob/master/src/Stream.php |
# |
Mar 2nd 2018, 13:55 |
admad |
https://github.com/php-fig/http-message/blob/master/src/StreamInterface.php |
# |
Mar 2nd 2018, 13:18 |
inoas |
just switch around the adapter from stream to non-stream and enable caching which would cache responses for the same get request (same url, same query params, same headers) |
# |
Mar 2nd 2018, 13:18 |
inoas |
I want things to look the same from the outside |
# |
Mar 2nd 2018, 13:18 |
inoas |
however the response cannot be cached because the adapter is a stream |