1
0
mirror of https://github.com/guzzle/guzzle.git synced 2025-02-24 18:13:00 +01:00

Test content-length and content-encoding with gzipped response

When the upstream response is transfered gzipped, we must test that
the returned response has valid content-length and content-encoding
for the returned body.
This commit is contained in:
Antonio J. García Lagar 2015-05-28 18:04:20 +02:00
parent 29afd334ba
commit 41d99927e8

View File

@ -139,6 +139,8 @@ class StreamHandlerTest extends \PHPUnit_Framework_TestCase
$request = new Request('GET', Server::$url);
$response = $handler($request, ['decode_content' => true])->wait();
$this->assertEquals('test', (string) $response->getBody());
$this->assertFalse($response->hasHeader('content-encoding'));
$this->assertTrue(!$response->hasHeader('content-length') || $response->getHeaderLine('content-length') == $response->getBody()->getSize());
}
public function testDoesNotForceGzipDecode()
@ -155,6 +157,8 @@ class StreamHandlerTest extends \PHPUnit_Framework_TestCase
$request = new Request('GET', Server::$url);
$response = $handler($request, ['decode_content' => false])->wait();
$this->assertSame($content, (string) $response->getBody());
$this->assertEquals('gzip', $response->getHeaderLine('content-encoding'));
$this->assertEquals(strlen($content), $response->getHeaderLine('content-length'));
}
public function testProtocolVersion()