예제 #1
0
 /**
  * @depends testSetAgent
  */
 public function testOverideExistingHeader(HeaderProvider $hp)
 {
     $headerStr = 'Agent';
     $value = 'Another Agent';
     $header = $hp->setHeader($headerStr, $value);
     $this->assertInstanceOf(Header::class, $header);
     $this->assertCount(1, $header->getContent());
     $this->assertEquals($value, $header->getContent()[0]);
 }
예제 #2
0
파일: Client.php 프로젝트: demvsystems/curl
 /**
  * @param string $url
  * @param        $data
  *
  * @return mixed|string
  */
 public function send(string $url, $data)
 {
     $this->setDefaults();
     $this->setOption(CURLOPT_URL, $url)->setOption(CURLOPT_POSTFIELDS, $data);
     if ($this->hasHeaderProvider()) {
         $this->setOption(CURLOPT_HTTPHEADER, $this->_headerProvider->provide());
     }
     $result = curl_exec($this->_handle);
     if ($result === false) {
         return curl_error($this->_handle);
     }
     return $result;
 }