Skip to content

Commit 86ac739

Browse files
authored
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.
1 parent 7d1504f commit 86ac739

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

src/Bigcommerce/Api/Connection.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -557,6 +557,13 @@ public function getHeader($header)
557557
if (array_key_exists($header, $this->responseHeaders)) {
558558
return $this->responseHeaders[$header];
559559
}
560+
foreach($this->responseHeaders as $k => $v)
561+
{
562+
if(strcasecmp($k, $header) == 0)
563+
{
564+
return $this->responseHeaders[$k];
565+
}
566+
}
560567
}
561568

562569
/**

0 commit comments

Comments
 (0)