setting custom curl options

- `Unirest\Request::curlOpt()`
- `Unirest\Request::curlOpts()`
- `Unirest\Request::clearCurlOpts()`

fixes #78
This commit is contained in:
Ahmad Nassri
2015-04-08 17:34:24 -04:00
parent ec5828c8aa
commit 4221ee5138
3 changed files with 84 additions and 29 deletions

View File

@@ -16,6 +16,17 @@ class UnirestRequestTest extends \PHPUnit_Framework_TestCase
$this->assertEquals($result['file'], $file);
}
public function testCurlOpts()
{
Unirest\Request::curlOpt(CURLOPT_COOKIE, 'foo=bar');
$response = Unirest\Request::get('http://mockbin.com/request');
$this->assertTrue(property_exists($response->body->cookies, 'foo'));
Unirest\Request::clearCurlOpts();
}
/**
* @expectedException Exception
*/
@@ -23,23 +34,11 @@ class UnirestRequestTest extends \PHPUnit_Framework_TestCase
{
Unirest\Request::timeout(1);
Unirest\Request::get('http://mockbin.com/delay/3000');
Unirest\Request::get('http://mockbin.com/delay/1000');
Unirest\Request::timeout(null); // Cleaning timeout for the other tests
}
/*
public function testTimeoutSuccess()
{
Unirest\Request::timeout(3);
$response = Unirest\Request::get('http://mockbin.com/delay/2000');
$this->assertEquals(200, $response->code);
Unirest\Request::timeout(null); // Cleaning timeout for the other tests
}
*/
public function testDefaultHeader()
{
Unirest\Request::defaultHeader('Hello', 'custom');