Compare commits
9 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
53656bf519 | ||
|
|
889ca14f5f | ||
|
|
45274fd536 | ||
|
|
a3446f6d99 | ||
|
|
e9ea4dbee2 | ||
|
|
d71cd15d4a | ||
|
|
2d0cd4c8d9 | ||
|
|
c01f685e3b | ||
|
|
28080c975c |
1
.gitignore
vendored
1
.gitignore
vendored
@@ -1,4 +1,5 @@
|
||||
.DS_Store
|
||||
.idea
|
||||
build
|
||||
composer.lock
|
||||
composer.phar
|
||||
|
||||
@@ -37,7 +37,7 @@ To install unirest-php with Composer, just add the following to your `composer.j
|
||||
```json
|
||||
{
|
||||
"require-dev": {
|
||||
"mashape/unirest-php": "2.*"
|
||||
"mashape/unirest-php": "3.*"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
@@ -159,7 +159,7 @@ class Request
|
||||
}
|
||||
|
||||
/**
|
||||
* Set a coockie string for enabling coockie handling
|
||||
* Set a cookie string for enabling cookie handling
|
||||
*
|
||||
* @param string $cookie
|
||||
*/
|
||||
@@ -169,7 +169,7 @@ class Request
|
||||
}
|
||||
|
||||
/**
|
||||
* Set a coockie file path for enabling coockie handling
|
||||
* Set a cookie file path for enabling cookie handling
|
||||
*
|
||||
* $cookieFile must be a correct path with write permission
|
||||
*
|
||||
@@ -399,7 +399,11 @@ class Request
|
||||
self::$handle = curl_init();
|
||||
|
||||
if ($method !== Method::GET) {
|
||||
curl_setopt(self::$handle, CURLOPT_CUSTOMREQUEST, $method);
|
||||
if ($method === Method::POST) {
|
||||
curl_setopt(self::$handle, CURLOPT_POST, true);
|
||||
} else {
|
||||
curl_setopt(self::$handle, CURLOPT_CUSTOMREQUEST, $method);
|
||||
}
|
||||
|
||||
curl_setopt(self::$handle, CURLOPT_POSTFIELDS, $body);
|
||||
} elseif (is_array($body)) {
|
||||
@@ -504,7 +508,7 @@ class Request
|
||||
{
|
||||
$formattedHeaders = array();
|
||||
|
||||
$combinedHeaders = array_change_key_case(array_merge((array) $headers, self::$defaultHeaders));
|
||||
$combinedHeaders = array_change_key_case(array_merge(self::$defaultHeaders, (array) $headers));
|
||||
|
||||
foreach ($combinedHeaders as $key => $val) {
|
||||
$formattedHeaders[] = self::getHeaderString($key, $val);
|
||||
|
||||
@@ -48,6 +48,12 @@ class UnirestRequestTest extends \PHPUnit_Framework_TestCase
|
||||
$this->assertObjectHasAttribute('header2', $response->body->headers);
|
||||
$this->assertEquals('world', $response->body->headers->header2);
|
||||
|
||||
$response = Request::get('http://mockbin.com/request', ['header1' => 'Custom value']);
|
||||
|
||||
$this->assertEquals(200, $response->code);
|
||||
$this->assertObjectHasAttribute('header1', $response->body->headers);
|
||||
$this->assertEquals('Custom value', $response->body->headers->header1);
|
||||
|
||||
Request::clearDefaultHeaders();
|
||||
|
||||
$response = Request::get('http://mockbin.com/request');
|
||||
|
||||
Reference in New Issue
Block a user