[HttpKernel] fixed Client when using StreamedResponses (closes #5370)
This commit is contained in:
parent
ae61d354c9
commit
84b760b923
@ -179,6 +179,11 @@ EOF;
|
|||||||
$headers['Set-Cookie'] = $cookies;
|
$headers['Set-Cookie'] = $cookies;
|
||||||
}
|
}
|
||||||
|
|
||||||
return new DomResponse($response->getContent(), $response->getStatusCode(), $headers);
|
// this is needed to support StreamResponse
|
||||||
|
ob_start();
|
||||||
|
$response->sendContent();
|
||||||
|
$content = ob_get_clean();
|
||||||
|
|
||||||
|
return new DomResponse($content, $response->getStatusCode(), $headers);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -15,6 +15,7 @@ use Symfony\Component\HttpKernel\Client;
|
|||||||
use Symfony\Component\HttpKernel\HttpKernel;
|
use Symfony\Component\HttpKernel\HttpKernel;
|
||||||
use Symfony\Component\HttpFoundation\Request;
|
use Symfony\Component\HttpFoundation\Request;
|
||||||
use Symfony\Component\HttpFoundation\Response;
|
use Symfony\Component\HttpFoundation\Response;
|
||||||
|
use Symfony\Component\HttpFoundation\StreamedResponse;
|
||||||
use Symfony\Component\HttpFoundation\Cookie;
|
use Symfony\Component\HttpFoundation\Cookie;
|
||||||
use Symfony\Component\HttpFoundation\File\UploadedFile;
|
use Symfony\Component\HttpFoundation\File\UploadedFile;
|
||||||
use Symfony\Component\HttpKernel\Tests\Fixtures\TestClient;
|
use Symfony\Component\HttpKernel\Tests\Fixtures\TestClient;
|
||||||
@ -86,6 +87,22 @@ class ClientTest extends \PHPUnit_Framework_TestCase
|
|||||||
$this->assertEquals($expected, $domResponse->getHeader('Set-Cookie', false));
|
$this->assertEquals($expected, $domResponse->getHeader('Set-Cookie', false));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testFilterResponseSupportsStreamedResponses()
|
||||||
|
{
|
||||||
|
$client = new Client(new TestHttpKernel());
|
||||||
|
|
||||||
|
$r = new \ReflectionObject($client);
|
||||||
|
$m = $r->getMethod('filterResponse');
|
||||||
|
$m->setAccessible(true);
|
||||||
|
|
||||||
|
$response = new StreamedResponse(function () {
|
||||||
|
echo 'foo';
|
||||||
|
});
|
||||||
|
|
||||||
|
$domResponse = $m->invoke($client, $response);
|
||||||
|
$this->assertEquals('foo', $domResponse->getContent());
|
||||||
|
}
|
||||||
|
|
||||||
public function testUploadedFile()
|
public function testUploadedFile()
|
||||||
{
|
{
|
||||||
$source = tempnam(sys_get_temp_dir(), 'source');
|
$source = tempnam(sys_get_temp_dir(), 'source');
|
||||||
|
Reference in New Issue
Block a user