Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[11.x] Provide an error message for PostTooLargeException #53301

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/Illuminate/Http/Middleware/ValidatePostSize.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public function handle($request, Closure $next)
$max = $this->getPostMaxSize();

if ($max > 0 && $request->server('CONTENT_LENGTH') > $max) {
throw new PostTooLargeException;
throw new PostTooLargeException('The POST data is too large.');
}

return $next($request);
Expand Down
11 changes: 7 additions & 4 deletions tests/Integration/Http/ResourceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@
use Illuminate\Tests\Integration\Http\Fixtures\SerializablePostResource;
use Illuminate\Tests\Integration\Http\Fixtures\Subscription;
use LogicException;
use Mockery as m;
use Orchestra\Testbench\TestCase;

class ResourceTest extends TestCase
Expand Down Expand Up @@ -1503,12 +1502,16 @@ public function work()

public function testPostTooLargeException()
{
$request = new Request(server: ['CONTENT_LENGTH' => '4']);
$post = new ValidatePostSize;
$post->handle($request, fn () => null);

$this->expectException(PostTooLargeException::class);
$this->expectExceptionMessage('The POST data is too large.');

$request = m::mock(Request::class, ['server' => ['CONTENT_LENGTH' => '2147483640']]);
$request = new Request(server: ['CONTENT_LENGTH' => '2147483640']);
$post = new ValidatePostSize;
$post->handle($request, function () {
});
$post->handle($request, fn () => null);
}

public function testLeadingMergeKeyedValueIsMergedCorrectlyWhenFirstValueIsMissing()
Expand Down