Skip to content

Commit 34fca08

Browse files
authored
Fix getHeader to be case-insensitive
On certain BigCommerce stores, getHeader fails because the X-BC-ApiLimit-Remaining header is all lower-case in the HTTP response. This causes getRequestsRemaining to always return 0 and puts the code into an infinite wait for more requests. Instead, change getHeader to do a case-insensitive search for the header if the exact case is not found. Please merge this into the trunk.
1 parent e6f8446 commit 34fca08

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

src/Bigcommerce/Api/Connection.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -556,6 +556,12 @@ public function getHeader($header)
556556
if (array_key_exists($header, $this->responseHeaders)) {
557557
return $this->responseHeaders[$header];
558558
}
559+
// Do case-insensitive search
560+
foreach($this->responseHeaders as $k => $v) {
561+
if(strtolower($k) == strtolower($header)) {
562+
return $v;
563+
}
564+
}
559565
}
560566

561567
/**

0 commit comments

Comments
 (0)