Skip to content

Commit

Permalink
bug #37065 [HttpClient] Throw JsonException instead of TransportExcep…
Browse files Browse the repository at this point in the history
…tion on empty response in Response::toArray() (jeroennoten)

This PR was merged into the 4.4 branch.

Discussion
----------

[HttpClient] Throw JsonException instead of TransportException on empty response in Response::toArray()

| Q             | A
| ------------- | ---
| Branch?       | 4.4
| Bug fix?      | yes
| New feature?  | no
| Deprecations? | no
| Tickets       | Fix #37064
| License       | MIT

Commits
-------

69547d9 [HttpClient] Throw JsonException instead of TransportException on empty response in Response::toArray()
  • Loading branch information
fabpot committed Jun 3, 2020
2 parents 950ff7e + 69547d9 commit fe61dd5
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
Expand Up @@ -137,7 +137,7 @@ public function getContent(bool $throw = true): string
public function toArray(bool $throw = true): array
{
if ('' === $content = $this->getContent($throw)) {
throw new TransportException('Response body is empty.');
throw new JsonException('Response body is empty.');
}

if (null !== $this->jsonData) {
Expand Down
Expand Up @@ -35,6 +35,12 @@ public function testToArrayError($content, $responseHeaders, $message)

public function toArrayErrors()
{
yield [
'content' => '',
'responseHeaders' => [],
'message' => 'Response body is empty.',
];

yield [
'content' => '{}',
'responseHeaders' => ['content-type' => 'plain/text'],
Expand Down

0 comments on commit fe61dd5

Please sign in to comment.