Exemplo n.º 1
0
 public function _initializeSession()
 {
     $defaults = array_intersect_key($this->config, array_flip($this->guzzleConfigFields));
     $defaults['config']['curl'] = $this->config['curl'];
     foreach ($this->config['curl'] as $key => $val) {
         if (defined($key)) {
             $defaults['config']['curl'][constant($key)] = $val;
         }
     }
     if ($this->isGuzzlePsr7) {
         $defaults['base_uri'] = $this->config['url'];
         $this->guzzle = new GuzzleClient($defaults);
     } else {
         $this->guzzle = new GuzzleClient(['base_url' => $this->config['url'], 'defaults' => $defaults]);
         $this->client->setBaseUri($this->config['url']);
     }
     $this->client->setRefreshMaxInterval($this->config['refresh_max_interval']);
     $this->client->setClient($this->guzzle);
 }
Exemplo n.º 2
0
 public function _initializeSession()
 {
     $defaults = array_intersect_key($this->config, array_flip($this->guzzleConfigFields));
     $curlOptions = [];
     foreach ($this->config['curl'] as $key => $val) {
         if (defined($key)) {
             $curlOptions[constant($key)] = $val;
         }
     }
     $this->setCookiesFromOptions();
     if ($this->isGuzzlePsr7) {
         $defaults['base_uri'] = $this->config['url'];
         $defaults['curl'] = $curlOptions;
         $handler = Guzzle6::createHandler($this->config['handler']);
         if ($handler && is_array($this->config['middleware'])) {
             foreach ($this->config['middleware'] as $middleware) {
                 $handler->push($middleware);
             }
         }
         $defaults['handler'] = $handler;
         $this->guzzle = new GuzzleClient($defaults);
     } else {
         $defaults['config']['curl'] = $curlOptions;
         $this->guzzle = new GuzzleClient(['base_url' => $this->config['url'], 'defaults' => $defaults]);
         $this->client->setBaseUri($this->config['url']);
     }
     $this->client->setRefreshMaxInterval($this->config['refresh_max_interval']);
     $this->client->setClient($this->guzzle);
 }