From 86ac739ef086baf7ea10eb7b593c64fde8a290b4 Mon Sep 17 00:00:00 2001 From: atensoftware Date: Fri, 14 Apr 2017 08:01:53 -0400 Subject: [PATCH] fix getHeader to be case-insensitive www.campman.com returns the "X-BC-ApiLimit-Remaining" header in all lower-case, like "x-bc-apilimit-remaining". The getRequestsRemaining can not find the header, and returns 0 as the limit every time. I patched the getHeader function so it will look for the header key using a case-insensitive search, if it can't find an exact match using the hash lookup. Now, getRequestsRemaining returns the expected number of API requests remaining. Note that RFC2616 states that field names in the HTTP header are case-insensitive, so this is the correct thing to do. --- src/Bigcommerce/Api/Connection.php | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/Bigcommerce/Api/Connection.php b/src/Bigcommerce/Api/Connection.php index 69ca63b9..75e6afcc 100644 --- a/src/Bigcommerce/Api/Connection.php +++ b/src/Bigcommerce/Api/Connection.php @@ -557,6 +557,13 @@ public function getHeader($header) if (array_key_exists($header, $this->responseHeaders)) { return $this->responseHeaders[$header]; } + foreach($this->responseHeaders as $k => $v) + { + if(strcasecmp($k, $header) == 0) + { + return $this->responseHeaders[$k]; + } + } } /**