Log message #4121358

# At Username Text
# Mar 2nd 2018, 14:39 hmic i guess he hinted you on the solution with the last sentence
# Mar 2nd 2018, 14:39 inoas defaulting to a new adapater is a piece of cake already
# Mar 2nd 2018, 14:38 inoas admad so there I am and I was wondering why Http\Client\Adapter\Stream had no Interface
# Mar 2nd 2018, 14:38 hmic ;-)
# Mar 2nd 2018, 14:38 admad then good luck extending and overriding required parts of Http\Client\Adapter\Stream and tell Http\Client to use that class using 'adapter' config
# Mar 2nd 2018, 14:38 hmic however, you need to recreate a response object from stored data in this case. which is, like admad said, non-trivial at best
# Mar 2nd 2018, 14:37 hmic what about directing your requests to a caching proxy to hide the complexity from the app *completely*? :P
# Mar 2nd 2018, 14:36 inoas some caches should be consumable - configure thing
# Mar 2nd 2018, 14:36 inoas so I can drop it in and it will behave based on a little bit of configuration exactly like Client ... or return things from cache depending on the same url/query-string/http-headers and cache-time-window
# Mar 2nd 2018, 14:35 inoas I want to basically change the class from Client to CachedClient and have maybe a few Configure::readOrFail() settings and then when a request comes in it either goes through or returns things from cache
# Mar 2nd 2018, 14:34 inoas admad but what I want to do is hide complexity from the app
# Mar 2nd 2018, 14:33 admad or maybe use something like this https://github.com/micheh/psr7-cache
# Mar 2nd 2018, 14:32 admad don't try to add caching directly in http client, it's non trivial. Just get the response string as i showed and cache. Then use whatever app logic you need to decide whether to make a new request or just used the cached response string
# Mar 2nd 2018, 14:31 hmic you will need to build up the response object from the cached data again, sure. you can't just store/serialize the object with all the state
# Mar 2nd 2018, 14:30 inoas I had problems with the adapter being a stream one
# Mar 2nd 2018, 14:30 inoas :(
# Mar 2nd 2018, 14:30 inoas I will try again
# Mar 2nd 2018, 14:30 inoas and for a cached response you would get back all the response code, response headers etc
# Mar 2nd 2018, 14:30 hmic inoas, so create a response in your class and feed the data you've got? whats the point?
# Mar 2nd 2018, 14:29 hmic thats about what i would have thought about the client too. who cares about the inner implementation, you get the body back anyways
# Mar 2nd 2018, 14:29 inoas much like $response = (new CachedClient)->get($url);
# Mar 2nd 2018, 14:29 inoas the signature
# Mar 2nd 2018, 14:29 inoas ah yes what I wanted to do is making sure that the interface does not change
# Mar 2nd 2018, 14:28 inoas I think I tried that, but I will take a look
# Mar 2nd 2018, 14:28 hmic the client could need some love probably anyways
# 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