Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix detection of secondary rate limit #1126

Merged
merged 2 commits into from
Nov 19, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/Github/HttpClient/Plugin/GithubExceptionThrower.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
/**
* @return Promise
*/
public function handleRequest(RequestInterface $request, callable $next, callable $first): Promise

Check failure on line 26 in lib/Github/HttpClient/Plugin/GithubExceptionThrower.php

View workflow job for this annotation

GitHub Actions / PHPStan

Method Github\HttpClient\Plugin\GithubExceptionThrower::handleRequest() has parameter $first with generic interface Http\Promise\Promise but does not specify its types: T

Check failure on line 26 in lib/Github/HttpClient/Plugin/GithubExceptionThrower.php

View workflow job for this annotation

GitHub Actions / PHPStan

Method Github\HttpClient\Plugin\GithubExceptionThrower::handleRequest() has parameter $next with generic interface Http\Promise\Promise but does not specify its types: T

Check failure on line 26 in lib/Github/HttpClient/Plugin/GithubExceptionThrower.php

View workflow job for this annotation

GitHub Actions / PHPStan

Method Github\HttpClient\Plugin\GithubExceptionThrower::handleRequest() return type with generic interface Http\Promise\Promise does not specify its types: T
{
return $next($request)->then(function (ResponseInterface $response) use ($request) {
if ($response->getStatusCode() < 400 || $response->getStatusCode() > 600) {
Expand Down Expand Up @@ -128,7 +128,7 @@
}

$reset = (int) ResponseMediator::getHeader($response, 'X-RateLimit-Reset');
if ((403 === $response->getStatusCode()) && 0 < $reset && isset($content['message']) && (0 === strpos($content['message'], 'You have exceeded a secondary rate limit.'))) {
if ((403 === $response->getStatusCode()) && 0 < $reset && isset($content['message']) && (0 === strpos($content['message'], 'You have exceeded a secondary rate limit'))) {
$limit = (int) ResponseMediator::getHeader($response, 'X-RateLimit-Limit');

throw new ApiLimitExceedException($limit, $reset);
Expand Down
Loading