Closed sagikazarmark closed 9 years ago
/cc @egeloen @ddeboer
In general: :+1:. Two questions:
Configuration
object that is passed instead of an array for $options
? One advantage is that it could make explicit which options are permitted by having appropriate setters such as setTimeout()
(but not setUserAgent()
).Packages requiring the adapter shouldn't really pass options to it. It is only there to make it possible, but is not always a good idea IMHO.
True, but those packages can just ignore the $options argument, so we end up with the default empty array.
You are right. I guess it is overseparation of interfaces 😃
So what should we do? Add it to the HttpAdapter instead?
On Sun, May 31, 2015 at 3:39 PM, Márk Sági-Kazár notifications@github.com wrote:
You are right. I guess it is overseparation of interfaces 😃
Reply to this email directly or view it on GitHub: https://github.com/php-http/adapter/pull/31#issuecomment-107181938
I've already done it, just haven't pushed it yet. ;)
Cool!
On Sun, May 31, 2015 at 4:48 PM, Márk Sági-Kazár notifications@github.com wrote:
I've already done it, just haven't pushed it yet. ;)
Reply to this email directly or view it on GitHub: https://github.com/php-http/adapter/pull/31#issuecomment-107200385
This PR adds a configurable HTTP Adapter interface to the Client separated adapter contract.
Rationale
There are some options in the underlying HTTP clients which cannot be controlled with a single message (request). For example timeout can only be passed directly to the guzzle client object. The extra optional
$options
argument serves this purpose.How does it work?
Since adapters are exchangeable, options should be abstracted away from underlying HTTP clients. The previously mentioned example (timeout) is a good start. Since the adapter tries to be a raw wrapper around clients providing a way to use PSR messages with them, options should be very limited. For example user agent, connection (previously available in adapters) should go away.
I can imagine that each adapter can provide a way to pass client specific options (for example under a
guzzle
key in the options array), but that should be avoided. However it does not break any interface to pass extra options.Why not a Configurable message implementation/decorator)
Earlier the plan was to create Configurable message implementations so that options can directly be passed with the request. The reason for that was to be able to pass options per request even in multi request case (
sendRequests
). In most cases parallel request sending is emulated since only curl based clients can send parallel requests. However those clients does not allow passing options per requests, only one option array for all the requests. Emulated multi request sending should also adhere that behavior.Some further pros of an options array:
withOption
methods