Skip to content

streamedResponse throws LogicException when setNotModified called #15564

Closed
@diarmuidie

Description

@diarmuidie

Calling setNotModified() on a streamedResponse throws a LogicException: The Response callback must not be null. exception.

On a regularresponse the content is set to null during setNotModified however because a streamedResponse uses a callback it is still being called.

I've created a branch with a failing test to demonstrate: https://github.com/diarmuidie/symfony/tree/failing-not-modified-streamed-response-test

$ phpunit --filter=testSetNotModified
PHPUnit 4.7.7 by Sebastian Bergmann and contributors.

.E

Time: 9.63 seconds, Memory: 157.50Mb

There was 1 error:

1) Symfony\Component\HttpFoundation\Tests\StreamedResponseTest::testSetNotModified
LogicException: The Response callback must not be null.

/Users/diarmuid/Projects/symfony/src/Symfony/Component/HttpFoundation/StreamedResponse.php:100
/Users/diarmuid/Projects/symfony/src/Symfony/Component/HttpFoundation/Response.php:315
/Users/diarmuid/Projects/symfony/src/Symfony/Component/HttpFoundation/Tests/StreamedResponseTest.php:120

FAILURES!
Tests: 2, Assertions: 7, Errors: 1.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions