3
namespace GuzzleHttp\Adapter;
6
* Sends streaming requests to a streaming compatible adapter while sending all
7
* other requests to a default adapter.
9
* This, for example, could be useful for taking advantage of the performance
10
* benefits of the CurlAdapter while still supporting true streaming through
13
class StreamingProxyAdapter implements AdapterInterface
15
private $defaultAdapter;
16
private $streamingAdapter;
19
* @param AdapterInterface $defaultAdapter Adapter used for non-streaming responses
20
* @param AdapterInterface $streamingAdapter Adapter used for streaming responses
22
public function __construct(
23
AdapterInterface $defaultAdapter,
24
AdapterInterface $streamingAdapter
26
$this->defaultAdapter = $defaultAdapter;
27
$this->streamingAdapter = $streamingAdapter;
30
public function send(TransactionInterface $transaction)
32
return $transaction->getRequest()->getConfig()['stream']
33
? $this->streamingAdapter->send($transaction)
34
: $this->defaultAdapter->send($transaction);