public function testHeadersAndBody() { $c = new Curl('http://www.popphp.org/version', array(CURLOPT_HEADER => true, CURLOPT_RETURNTRANSFER => true)); $c->execute(); $this->assertEquals('text/plain', $c->getHeader('Content-Type')); $this->assertGreaterThan(1, count($c->getHeaders())); $this->assertContains('HTTP', $c->getRawHeader()); $this->assertEquals('1.7.0', $c->getBody()); $this->assertEquals('200', $c->getCode()); $this->assertEquals('1.1', $c->getHttpVersion()); $this->assertEquals('OK', $c->getMessage()); }
<?php require_once '../../bootstrap.php'; use Pop\Curl\Curl; try { $curl = new Curl('http://www.popphp.org/license'); $curl->execute(); header('Content-Type: ' . $curl->getHeader('Content-Type')); echo $curl->getBody(); } catch (\Exception $e) { echo $e->getMessage() . PHP_EOL . PHP_EOL; }