Skip to content

Commit 11c3a50

Browse files
authored
Update SetAPIResponseHeaders.php
1 parent fca63b9 commit 11c3a50

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

app/Http/Middleware/SetAPIResponseHeaders.php

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,8 @@ class SetAPIResponseHeaders extends ThrottleRequests
2222
*/
2323
protected function getHeaders($maxAttempts, $remainingAttempts, $retryAfter = null, ?Response $response = null)
2424
{
25-
if ($response &&
26-
! is_null($response->headers->get('X-RateLimit-Remaining')) &&
27-
(int) $response->headers->get('X-RateLimit-Remaining') <= (int) $remainingAttempts) {
25+
$remaining = $response?->headers?->get('X-RateLimit-Remaining');
26+
if (!is_null($remaining) && (int) $remaining <= (int) $remainingAttempts) {
2827
$headers = [];
2928
$headers['Retry-After'] = $retryAfter; // this is the only line we changed
3029
$headers['X-RateLimit-Reset'] = $retryAfter; // this is the only line we changed
@@ -79,4 +78,4 @@ protected function handleRequest($request, Closure $next, array $limits)
7978
return $response;
8079
}
8180

82-
}
81+
}

0 commit comments

Comments
 (0)