Skip to content

Commit

Permalink
Merge pull request #46 from bookboon/hotfix/headers-case-insensitive
Browse files Browse the repository at this point in the history
All headers are now returned in lower-case form. Might be probablemat…
  • Loading branch information
lkm committed Feb 13, 2020
2 parents 3a14956 + d1173c1 commit ffea700
Show file tree
Hide file tree
Showing 6 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion src/Client/BasicAuthClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ private function decodeHeaders(string $headers) : array

$headerKey = trim(substr($header, 0, $separator));
$headerKey = implode('-', array_map('ucfirst', explode('-', $headerKey)));
$headerArray[$headerKey] = trim(substr($header, $separator + 1));
$headerArray[strtolower($headerKey)] = trim(substr($header, $separator + 1));
}

return $headerArray;
Expand Down
2 changes: 1 addition & 1 deletion src/Client/BookboonResponse.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public function getHeaders() : array
public function getReturnArray() : array
{
if ($this->getStatus() >= 300) {
return ['url' => $this->getHeaders()['Location']];
return ['url' => $this->getHeaders()['location']];
}

$json = json_decode($this->body, true);
Expand Down
2 changes: 1 addition & 1 deletion src/Client/OauthClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ protected function normalizeHeaders(array $headers) : array
{
$returnHeaders = [];
foreach ($headers as $key => $header) {
$returnHeaders[$key] = $header[0] ?? $header;
$returnHeaders[strtolower($key)] = $header[0] ?? $header;
}

return $returnHeaders;
Expand Down
6 changes: 3 additions & 3 deletions tests/Client/BasicAuthClientTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public function testBadAuthentication()
public function testNonExistingHeader()
{
$headers = "HTTP/1.1 200 OK\n Content-Type: application/json; charset=utf-8\nServer: Microsoft-IIS/8.0";
$result = \Helpers::invokeMethod(self::$client, 'getResponseHeader', [[$headers], 'Location']);
$result = \Helpers::invokeMethod(self::$client, 'getResponseHeader', [[$headers], 'location']);

$this->assertEmpty($result);
}
Expand All @@ -51,7 +51,7 @@ public function testValidHeader()
{
$headers = "HTTP/1.1 200 OK\n Content-Type: application/json; charset=utf-8\nServer: Microsoft-IIS/8.0\nLocation: http://bookboon.com";
$headerArray = \Helpers::invokeMethod(self::$client, 'decodeHeaders', [$headers]);
$result = $headerArray['Location'];
$result = $headerArray['location'];

$this->assertEquals('http://bookboon.com', $result);
}
Expand Down Expand Up @@ -81,4 +81,4 @@ public function testNotSupportedMethods($method)
}
self::$client->$method($param, "b");
}
}
}
2 changes: 1 addition & 1 deletion tests/Client/BookboonResponseTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class BookboonResponseTest extends TestCase
{
public function testRedirectResponse() {
$testUrl = 'http://test.com';
$bResponse = new BookboonResponse('', 302, ['Location' => $testUrl]);
$bResponse = new BookboonResponse('', 302, ['location' => $testUrl]);

$this->assertEquals(['url' => $testUrl], $bResponse->getReturnArray());
}
Expand Down
2 changes: 1 addition & 1 deletion tests/Entity/JourneyTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public function testFirstAllJourneysData()

public function testGetJourney()
{
$data = Journey::get(self::$bookboon, '010e0268-0eec-4859-a67a-ce41ee2315c4')
$data = Journey::get(self::$bookboon, '40b8b453-4ce9-425b-baa9-a8d88a589e3d')
->getEntityStore()
->get()[0];

Expand Down

0 comments on commit ffea700

Please sign in to comment.