diff --git a/.travis.yml b/.travis.yml index 88910965..7987546b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,11 +1,15 @@ language: php -php: - - 7 - - 5.6 - - 5.5 - - 5.4 - - 5.3 - - hhvm +jobs: + include: + - php: 7 + - php: 5.6 + - php: 5.5 + dist: precise + - php: 5.4 + dist: precise + - php: 5.3 + dist: precise + - php: hhvm sudo: false install: - composer install --dev diff --git a/CHANGELOG.md b/CHANGELOG.md index c5e8fa8f..2cfe5b68 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Recurly PHP Client Library CHANGELOG +## Version 2.7.3 (October 1, 2020) + +* Fixed issue with RFC 2616 compliance: headers should be treated as case-insensitive. + ## Version 2.7.2 (March 21st, 2017) * Require export files [#296](https://github.com/recurly/recurly-client-php/pull/296) diff --git a/Tests/bootstrap.php b/Tests/bootstrap.php index 3a762f55..9c973eab 100644 --- a/Tests/bootstrap.php +++ b/Tests/bootstrap.php @@ -75,8 +75,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)) diff --git a/lib/recurly/client.php b/lib/recurly/client.php index d7ae4f5f..2c82b802 100644 --- a/lib/recurly/client.php +++ b/lib/recurly/client.php @@ -44,7 +44,7 @@ class Recurly_Client */ private $_acceptLanguage = 'en-US'; - const API_CLIENT_VERSION = '2.7.2'; + const API_CLIENT_VERSION = '2.7.3'; const DEFAULT_ENCODING = 'UTF-8'; const GET = 'GET'; @@ -189,8 +189,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; } diff --git a/lib/recurly/coupon.php b/lib/recurly/coupon.php index dda6d209..3ee27903 100644 --- a/lib/recurly/coupon.php +++ b/lib/recurly/coupon.php @@ -80,7 +80,7 @@ public function generate($number) { $response->assertValidResponse(); $coupons = array(); - foreach (new Recurly_UniqueCouponCodeList($response->headers['Location'], $this->_client) as $coupon) { + foreach (new Recurly_UniqueCouponCodeList($response->headers['location'], $this->_client) as $coupon) { $coupons[] = $coupon; if (count($coupons) == $number) break; } diff --git a/lib/recurly/pager.php b/lib/recurly/pager.php index 9adb0f71..da166423 100644 --- a/lib/recurly/pager.php +++ b/lib/recurly/pager.php @@ -120,8 +120,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++) { @@ -136,8 +136,8 @@ private function _loadLinks($response) { */ private function _loadRecordCount($response) { - if (isset($response->headers['X-Records'])) { - $this->_count = intval($response->headers['X-Records']); + if (isset($response->headers['x-records'])) { + $this->_count = intval($response->headers['x-records']); } } diff --git a/lib/recurly/response.php b/lib/recurly/response.php index ca4d2335..6993be66 100644 --- a/lib/recurly/response.php +++ b/lib/recurly/response.php @@ -41,8 +41,8 @@ public function assertSuccessResponse($object) public function assertValidResponse() { - if (!empty($this->headers['Recurly-Deprecated'])) { - error_log("WARNING: API version {$this->headers['X-Api-Version']} is deprecated and will only be available until {$this->headers['Recurly-Sunset-Date']}. Please upgrade the Recurly PHP client."); + if (!empty($this->headers['recurly-deprecated'])) { + error_log("WARNING: API version {$this->headers['x-api-version']} is deprecated and will only be available until {$this->headers['recurly-sunset-date']}. Please upgrade the Recurly PHP client."); } // Successful response code