@@ 16-33 (lines=18) @@ | ||
13 | * @copyright 2016 Nathan Bishop |
|
14 | * @license The MIT license. |
|
15 | */ |
|
16 | class PayloadTooLarge extends ClientError |
|
17 | { |
|
18 | /** |
|
19 | * Construct a new 'Payload Too Large' exception. |
|
20 | * |
|
21 | * @param DateTimeInterface|null $retryAfter How long before the client should retry the request. |
|
22 | * @param string[][] $headers Additional headers associated with the exception. |
|
23 | */ |
|
24 | public function __construct(DateTimeInterface $retryAfter = null, array $headers = []) |
|
25 | { |
|
26 | if ($retryAfter) { |
|
27 | $retryAfter = [$retryAfter->format('D, d M Y H:i:s \G\M\T')]; |
|
28 | $headers = array_merge($headers, ['retry-after' => $retryAfter]); |
|
29 | } |
|
30 | ||
31 | parent::__construct(413, 'Payload Too Large', $headers); |
|
32 | } |
|
33 | } |
|
34 |
@@ 16-33 (lines=18) @@ | ||
13 | * @copyright 2016 Nathan Bishop |
|
14 | * @license The MIT license. |
|
15 | */ |
|
16 | class TooManyRequests extends ClientError |
|
17 | { |
|
18 | /** |
|
19 | * Construct a new 'Too Many Requests' exception. |
|
20 | * |
|
21 | * @param DateTimeInterface|null $retryAfter How long before the client should retry the request. |
|
22 | * @param string[][] $headers Additional headers associated with the exception. |
|
23 | */ |
|
24 | public function __construct(DateTimeInterface $retryAfter = null, array $headers = []) |
|
25 | { |
|
26 | if ($retryAfter) { |
|
27 | $retryAfter = [$retryAfter->format('D, d M Y H:i:s \G\M\T')]; |
|
28 | $headers = array_merge($headers, ['retry-after' => $retryAfter]); |
|
29 | } |
|
30 | ||
31 | parent::__construct(429, 'Too Many Requests', $headers); |
|
32 | } |
|
33 | } |
|
34 |
@@ 16-33 (lines=18) @@ | ||
13 | * @copyright 2016 Nathan Bishop |
|
14 | * @license The MIT license. |
|
15 | */ |
|
16 | class ServiceUnavailable extends ServerError |
|
17 | { |
|
18 | /** |
|
19 | * Construct a new 'Service Unavailable' exception. |
|
20 | * |
|
21 | * @param DateTimeInterface|null $retryAfter If provided, how long the client should wait before retrying the request. |
|
22 | * @param string[][] $headers Additional headers associated with the exception. |
|
23 | */ |
|
24 | public function __construct(DateTimeInterface $retryAfter = null, array $headers = []) |
|
25 | { |
|
26 | if ($retryAfter) { |
|
27 | // RFC7231, Section 7.1.1: http://tools.ietf.org/html/rfc7231 |
|
28 | $headers = array_merge($headers, ['retry-after' => [$retryAfter->format('D, d M Y H:i:s \G\M\T')]]); |
|
29 | } |
|
30 | ||
31 | parent::__construct(503, 'Service Unavailable', $headers); |
|
32 | } |
|
33 | } |
|
34 |