Skip to content

Commit 692e9ea

Browse files
Add support for 429 Too Many Requests HTTP status code
1 parent f87f063 commit 692e9ea

File tree

3 files changed

+12
-20
lines changed

3 files changed

+12
-20
lines changed

src/Api/BaseApiClient.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,8 @@ class BaseApiClient
5353
HttpStatusCode::FORBIDDEN => NotAllowed::class,
5454
HttpStatusCode::NOT_FOUND => NotFound::class,
5555
HttpStatusCode::CONFLICT => AlreadyExists::class,
56-
HttpStatusCode::ENHANCE_YOUR_CALM => RateLimited::class, // RFC6585::TOO_MANY_REQUESTS
56+
HttpStatusCode::ENHANCE_YOUR_CALM => RateLimited::class,
57+
HttpStatusCode::TOO_MANY_REQUESTS => RateLimited::class,
5758
HttpStatusCode::INTERNAL_SERVER_ERROR => GeneralError::class,
5859
];
5960

src/Api/Utils/HttpStatusCode.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,16 @@ class HttpStatusCode
9090
*/
9191
public const ENHANCE_YOUR_CALM = 420;
9292

93+
/**
94+
* The 429 (Too Many Requests) status code indicates the user has sent too
95+
* many requests in a given amount of time ("rate limiting").
96+
*
97+
* @link https://datatracker.ietf.org/doc/html/rfc6585#section-4
98+
*
99+
* @var int
100+
*/
101+
public const TOO_MANY_REQUESTS = 429;
102+
93103
/**
94104
* The 500 (Internal Server Error) status code indicates that the server
95105
* encountered an unexpected condition that prevented it from fulfilling the

tests/Integration/Search/SearchApiTest.php

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -281,25 +281,6 @@ public function testFindAssetsByGeneralExpression()
281281
self::assertValidAsset($result['resources'][0]);
282282
}
283283

284-
/**
285-
* Find assets without limiting expression to certain fields but with an underscore in the expression
286-
* Shows results containing the entire expression in any string field
287-
* Shows results containing the entire expression or a part of it (parts are separated by underscore) in public_id
288-
*
289-
* @throws ApiError
290-
*/
291-
public function testFindAssetsByGeneralExpressionWithUnderscore()
292-
{
293-
$result = $this->search
294-
->expression(self::$MULTI_STRING)
295-
->maxResults(2)
296-
->execute();
297-
298-
self::assertEquals(2, $result['total_count']);
299-
self::assertCount(2, $result['resources']);
300-
self::assertValidAsset($result['resources'][0]);
301-
}
302-
303284
/**
304285
* Find assets with an expression limiting the search expression to certain fields
305286
* Shows results containing given text in tags field

0 commit comments

Comments
 (0)