Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updating client to be compliant with RFC 2616: case-insensitive headers #546

Merged
merged 1 commit into from
Oct 1, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.1.5 (October 1, 2020)

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

## Version 2.1.4 (February 19, 2013)

* Fixed fatal error in Recurly_Invoice::getInvoicePdf().
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"ext-curl": "*"
},
"require-dev": {
"lastcraft/simpletest": "1.1.*"
"simpletest/simpletest": "1.1.*"
},
"autoload": {
"classmap": ["lib"]
Expand Down
8 changes: 5 additions & 3 deletions lib/recurly/client.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class Recurly_Client
*/
private $_acceptLanguage = 'en-US';

const API_CLIENT_VERSION = '2.1.2';
const API_CLIENT_VERSION = '2.1.5';
const DEFAULT_ENCODING = 'UTF-8';

const GET = 'GET';
Expand Down Expand Up @@ -160,8 +160,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
2 changes: 1 addition & 1 deletion test/all_tests.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php

require_once(__DIR__ . '/../vendor/autoload.php');
require_once(__DIR__ . '/../vendor/lastcraft/simpletest/autorun.php');
require_once(__DIR__ . '/../vendor/simpletest/simpletest/autorun.php');
require_once(__DIR__ . '/test_helpers.php');


Expand Down
6 changes: 4 additions & 2 deletions test/test_helpers.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,10 @@ function loadFixture($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