Use lowercase Github ratelimit headers to determine the ratelimit limit and reset time (#11194)
https://github.com/github/docs/pull/14912pull/11316/head
parent
bf451bd089
commit
fd62c6eb58
|
@ -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;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue