decode_content
Summary
Specify whether or not Content-Encoding
responses (gzip, deflate, etc.) are automatically decoded.
Types
- string
- bool
Default
true
Constant
GuzzleHttp\RequestOptions::DECODE_CONTENT
This option can be used to control how content-encoded response bodies are handled. By default, decode_content
is set to true, meaning any gzipped or deflated response will be decoded by Guzzle.
When set to false
, the body of a response is never decoded, meaning the bytes pass through the handler unchanged.
// Request gzipped data, but do not decode it while downloading
$client->request('GET', '/foo.js', [
'headers' => ['Accept-Encoding' => 'gzip'],
'decode_content' => false
]);
When set to a string, the bytes of a response are decoded and the string value provided to the decode_content
option is passed as the Accept-Encoding
header of the request.
// Pass "gzip" as the Accept-Encoding header.
$client->request('GET', '/foo.js', ['decode_content' => 'gzip']);