Method
CurlResponse::getBody
Return the body stream, without waiting for the transfer.
Description#
public CurlResponse::getBody(): StreamInterfaceReading from the stream waits for data. The stream is read once and cannot be rewound.
When the transfer failed, the read that reaches the failure throws a NetworkException
(or the ClientException that matches the failure) instead of returning an empty string.
Return values#
StreamInterface
Errors / Exceptions#
| Exception | When |
|---|---|
ClientException | From a read, when the transfer failed |
Examples#
$json = \json_decode((string) $client->get('https://example.com/data.json')->getBody(), true);See also#
CurlResponse::getStatusCodeReturn the HTTP status code, waiting for the headers to arrive.