1
0
Fork 0

Use lowercase Github ratelimit headers to determine the ratelimit limit and reset time (#11194)

https://github.com/github/docs/pull/14912
pull/11316/head
PrinsFrank 2022-11-24 14:33:37 +01:00 committed by Jordi Boggiano
parent bf451bd089
commit fd62c6eb58
No known key found for this signature in database
GPG Key ID: 7BBD42C429EC80BC
1 changed files with 4 additions and 4 deletions

View File

@ -154,15 +154,15 @@ class GitHub
foreach ($headers as $header) { foreach ($headers as $header) {
$header = trim($header); $header = trim($header);
if (false === strpos($header, 'X-RateLimit-')) { if (false === stripos($header, 'x-ratelimit-')) {
continue; continue;
} }
list($type, $value) = explode(':', $header, 2); list($type, $value) = explode(':', $header, 2);
switch ($type) { switch (strtolower($type)) {
case 'X-RateLimit-Limit': case 'x-ratelimit-limit':
$rateLimit['limit'] = (int) trim($value); $rateLimit['limit'] = (int) trim($value);
break; break;
case 'X-RateLimit-Reset': case 'x-ratelimit-reset':
$rateLimit['reset'] = date('Y-m-d H:i:s', (int) trim($value)); $rateLimit['reset'] = date('Y-m-d H:i:s', (int) trim($value));
break; break;
} }