mirror of
https://github.com/guzzle/guzzle.git
synced 2025-01-18 05:48:15 +01:00
Merge pull request #1621 from cnanney/master
Don't include summary in exception message when body is empty
This commit is contained in:
commit
58219b370b
@ -131,6 +131,11 @@ class RequestException extends TransferException
|
||||
}
|
||||
|
||||
$size = $body->getSize();
|
||||
|
||||
if ($size === 0) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$summary = $body->read(120);
|
||||
$body->rewind();
|
||||
|
||||
|
@ -109,6 +109,12 @@ class RequestExceptionTest extends \PHPUnit_Framework_TestCase
|
||||
$this->assertContains($expected, $e->getMessage());
|
||||
}
|
||||
|
||||
public function testExceptionMessageIgnoresEmptyBody()
|
||||
{
|
||||
$e = RequestException::create(new Request('GET', '/'), new Response(500));
|
||||
$this->assertStringEndsWith('response', $e->getMessage());
|
||||
}
|
||||
|
||||
public function testCreatesExceptionWithoutPrintableBody()
|
||||
{
|
||||
$response = new Response(
|
||||
@ -124,7 +130,8 @@ class RequestExceptionTest extends \PHPUnit_Framework_TestCase
|
||||
$this->assertInstanceOf('GuzzleHttp\Exception\RequestException', $e);
|
||||
}
|
||||
|
||||
public function testHasStatusCodeAsExceptionCode() {
|
||||
public function testHasStatusCodeAsExceptionCode()
|
||||
{
|
||||
$e = RequestException::create(new Request('GET', '/'), new Response(442));
|
||||
$this->assertEquals(442, $e->getCode());
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user