decode_content
- Summary
Specify whether or notContent-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 arehandled. By default,
decode_content
is set to true, meaning any gzippedor deflated response will be decoded by Guzzle.
When set to false
, the body of a response is never decoded, meaning thebytes 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 valueprovided 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']);