示例#1
0
文件: HttpRequest.php 项目: blar/http
 /**
  * @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;
 }
示例#2
0
文件: CurlTest.php 项目: blar/curl
 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);
 }
示例#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);
 }
示例#4
0
文件: CurlProxy.php 项目: blar/curl
 /**
  * @param Curl $curl
  */
 public function setCurlOptions(Curl $curl)
 {
     $curl->setOptions($this->getOptions());
 }