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) {
$header = trim($header);
if (false === strpos($header, 'X-RateLimit-')) {
if (false === stripos($header, 'x-ratelimit-')) {
continue;
}
list($type, $value) = explode(':', $header, 2);
switch ($type) {
case 'X-RateLimit-Limit':
switch (strtolower($type)) {
case 'x-ratelimit-limit':
$rateLimit['limit'] = (int) trim($value);
break;
case 'X-RateLimit-Reset':
case 'x-ratelimit-reset':
$rateLimit['reset'] = date('Y-m-d H:i:s', (int) trim($value));
break;
}