/** * @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]); }
/** * @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; }