Skip to content

Commit d786665

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

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
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

0 commit comments

Comments
 (0)