示例#1
0
 /**
  * @dataProvider provideInvalidHosts
  */
 public function testSendToInvalidUrl($host)
 {
     $this->setExpectedException('RuntimeException');
     $request = new Message\Request();
     $request->fromUrl('http://' . $host . ':12345');
     $response = new Message\Response();
     $client = new FileGetContents();
     $client->setTimeout(0.05);
     $client->send($request, $response);
 }
示例#2
0
 /**
  * {@inheritdoc}
  */
 public function createClient(array $config = [])
 {
     if (!class_exists('Http\\Adapter\\Buzz\\Client')) {
         throw new \LogicException('To use the Buzz adapter you need to install the "php-http/buzz-adapter" package.');
     }
     $client = new FileGetContents();
     $options = $this->getOptions($config);
     $client->setTimeout($options['timeout']);
     $client->setVerifyPeer($options['verify_peer']);
     $client->setVerifyHost($options['verify_host']);
     $client->setProxy($options['proxy']);
     return new Adapter($client, $this->messageFactory);
 }
 public function getBrowser($_client, $_timeout)
 {
     switch ($_client) {
         case 'curl':
             $client = new Curl();
             break;
         case 'file_get_contents':
             $client = new FileGetContents();
             break;
         default:
             throw new \Exception('Client type "' . $_client . '" is invalid');
     }
     $client->setTimeout($_timeout);
     return new Browser($client);
 }