Skip to content

Commit

Permalink
Merge pull request #98 from RusinovIG/master
Browse files Browse the repository at this point in the history
Issue with priority of headers
  • Loading branch information
Ahmad Nassri committed Mar 23, 2016
2 parents 2bedcf0 + 28080c9 commit c01f685
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 1 deletion.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
.DS_Store
.idea
build
composer.lock
composer.phar
Expand Down
2 changes: 1 addition & 1 deletion src/Unirest/Request.php
Original file line number Diff line number Diff line change
Expand Up @@ -504,7 +504,7 @@ public static function getFormattedHeaders($headers)
{
$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);
Expand Down
6 changes: 6 additions & 0 deletions tests/Unirest/RequestTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,12 @@ public function testDefaultHeaders()
$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');
Expand Down

0 comments on commit c01f685

Please sign in to comment.