Example #1
0
 /**
  * @return \Blar\Curl\Curl
  */
 public function createCurl()
 {
     $curl = new Curl();
     $curl->setOptions(array(CURLOPT_PROTOCOLS => CURLPROTO_HTTP | CURLPROTO_HTTPS, CURLOPT_REDIR_PROTOCOLS => CURLPROTO_HTTP | CURLPROTO_HTTPS, CURLOPT_FOLLOWLOCATION => TRUE, CURLOPT_MAXREDIRS => 8));
     $curl->setUserAgent('blar/http');
     return $curl;
 }
Example #2
0
 public function testOptions()
 {
     $curl = new Curl();
     $curl->setOptions([CURLOPT_URL => 'http://httpbin.org/headers', CURLOPT_HTTPHEADER => ['Foo: 23', 'Bar: 42']]);
     $response = $curl->execute();
     $data = json_decode($response);
     $this->assertEquals(23, $data->headers->Foo);
     $this->assertEquals(42, $data->headers->Bar);
 }
Example #3
0
 public function testRequest()
 {
     $this->markTestSkipped('Benötigt einen lokalen Proxyserver');
     $proxy = new CurlProxy();
     $socket = new NetworkSocket('127.0.0.1', 3128);
     $proxy->setSocket($socket);
     $curl = new Curl();
     $curl->setProxy($proxy);
     $curl->setOptions([CURLOPT_URL => 'http://httpbin.org/headers', CURLOPT_HTTPHEADER => ['Foo: 23', 'Bar: 42']]);
     $response = $curl->execute();
     $data = json_decode($response);
     $this->assertEquals(23, $data->headers->Foo);
     $this->assertEquals(42, $data->headers->Bar);
 }
Example #4
0
 /**
  * @param Curl $curl
  */
 public function setCurlOptions(Curl $curl)
 {
     $curl->setOptions($this->getOptions());
 }