Beispiel #1
0
 /**
  * @param ClientInterface|Browser|null $client
  * @param ResponseFactory|null         $responseFactory
  */
 public function __construct($client = null, ResponseFactory $responseFactory = null)
 {
     $this->client = $client;
     if ($this->client === null) {
         $this->client = new FileGetContents();
         $this->client->setMaxRedirects(0);
     }
     if (!$this->client instanceof ClientInterface && !$this->client instanceof Browser) {
         throw new \InvalidArgumentException(sprintf('The client passed to the Buzz adapter must either implement %s or be an instance of %s. You passed %s.', ClientInterface::class, Browser::class, is_object($client) ? get_class($client) : gettype($client)));
     }
     $this->responseFactory = $responseFactory ?: MessageFactoryDiscovery::find();
 }
Beispiel #2
0
 protected function call()
 {
     $this->request->setMethod($this->call->getMethod());
     $this->request->setHost($this->call->getRequestPartBase());
     $this->request->setResource($this->call->getRequestPartUri());
     $this->request->setHeaders($this->headers->getHeaders());
     if ($this->call->getFormattedBody()) {
         $this->request->setContent($this->call->getFormattedBody());
     }
     $this->client->setIgnoreErrors(true);
     $this->client->setVerifyPeer($this->configuration->getVerifyPeer());
     $this->client->setMaxRedirects(0);
     $this->client->setTimeout(60);
     $this->client->send($this->request, $this->response);
 }