Skip to content

Commit

Permalink
Updating client to be compliant with RFC 2616: case-insensitive headers
Browse files Browse the repository at this point in the history
  • Loading branch information
douglasmiller committed Oct 1, 2020
1 parent 3c677d5 commit cac0c63
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 8 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Recurly PHP Client Library CHANGELOG

## Version 2.0.9 (October 1, 2020)

* Fixed issue with RFC 2616 compliance: headers should be treated as case-insensitive.

## Version 2.2.6 (May 9th, 2014)

* Added support for `Recurly_Account` field `balance_in_cents_invoiced` [#64]
Expand Down
6 changes: 4 additions & 2 deletions Tests/test_helpers.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,10 @@ protected function responseFromFixture($filename) {
break;
}
preg_match('/([^:]+): (.*)/', $fixture[$i], $matches);
if (sizeof($matches) > 2)
$headers[$matches[1]] = $matches[2];
if (sizeof($matches) > 2) {
$headerKey = strtolower($matches[1]);
$headers[$headerKey] = $matches[2];
}
}

if ($bodyLineNumber < sizeof($fixture))
Expand Down
6 changes: 4 additions & 2 deletions lib/recurly/client.php
Original file line number Diff line number Diff line change
Expand Up @@ -175,8 +175,10 @@ private function _getHeaders($headerText)
$returnHeaders = array();
foreach ($headers as &$header) {
preg_match('/([^:]+): (.*)/', $header, $matches);
if (sizeof($matches) > 2)
$returnHeaders[$matches[1]] = $matches[2];
if (sizeof($matches) > 2) {
$headerKey = strtolower($matches[1]);
$returnHeaders[$headerKey] = $matches[2];
}
}
return $returnHeaders;
}
Expand Down
8 changes: 4 additions & 4 deletions lib/recurly/pager.php
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,8 @@ protected static function _setState($params, $state) {
private function _loadLinks($response) {
$this->_links = array();

if (isset($response->headers['Link'])) {
$links = $response->headers['Link'];
if (isset($response->headers['link'])) {
$links = $response->headers['link'];
preg_match_all('/\<([^>]+)\>; rel=\"([^"]+)\"/', $links, $matches);
if (sizeof($matches) > 2) {
for ($i = 0; $i < sizeof($matches[1]); $i++) {
Expand All @@ -135,8 +135,8 @@ private function _loadLinks($response) {
*/
private function _loadRecordCount($response)
{
if (empty($this->_count) && isset($response->headers['X-Records']))
$this->_count = intval($response->headers['X-Records']);
if (empty($this->_count) && isset($response->headers['x-records']))
$this->_count = intval($response->headers['x-records']);
}

/**
Expand Down

0 comments on commit cac0c63

Please sign in to comment.