Skip to content

Commit 8f51150

Browse files
authored
Add handling for 413 upstream response (#2008)
1 parent 1d481fc commit 8f51150

2 files changed

Lines changed: 23 additions & 0 deletions

File tree

src/Transport/ResultStatus.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,15 @@ public static function success(): self
5757
return self::getInstance('SUCCESS');
5858
}
5959

60+
/**
61+
* Returns an instance of this enum representing the fact that the event
62+
* failed to be sent because the content was too large.
63+
*/
64+
public static function contentTooLarge(): self
65+
{
66+
return self::getInstance('CONTENT_TOO_LARGE');
67+
}
68+
6069
/**
6170
* Returns an instance of this enum representing the fact that the event
6271
* failed to be sent because of API rate limiting.
@@ -94,6 +103,8 @@ public static function createFromHttpStatusCode(int $statusCode): self
94103
switch (true) {
95104
case $statusCode >= 200 && $statusCode < 300:
96105
return self::success();
106+
case $statusCode === 413:
107+
return self::contentTooLarge();
97108
case $statusCode === 429:
98109
return self::rateLimit();
99110
case $statusCode >= 400 && $statusCode < 500:

tests/Transport/HttpTransportTest.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,18 @@ public static function sendDataProvider(): iterable
114114
],
115115
];
116116

117+
yield [
118+
new Response(413, [], ''),
119+
ResultStatus::contentTooLarge(),
120+
false,
121+
[
122+
'info' => [
123+
'Sending event [%s] to %s [project:%s].',
124+
'Sent event [%s] to %s [project:%s]. Result: "content_too_large" (status: 413).',
125+
],
126+
],
127+
];
128+
117129
ClockMock::withClockMock(1644105600);
118130

119131
yield [

0 commit comments

Comments
 (0)