private function StreamHandler::checkDecode in Zircon Profile 8
Same name and namespace in other branches
- 8.0 vendor/guzzlehttp/guzzle/src/Handler/StreamHandler.php \GuzzleHttp\Handler\StreamHandler::checkDecode()
1 call to StreamHandler::checkDecode()
- StreamHandler::createResponse in vendor/
guzzlehttp/ guzzle/ src/ Handler/ StreamHandler.php
File
- vendor/
guzzlehttp/ guzzle/ src/ Handler/ StreamHandler.php, line 145
Class
- StreamHandler
- HTTP handler that uses PHP's HTTP stream wrapper.
Namespace
GuzzleHttp\HandlerCode
private function checkDecode(array $options, array $headers, $stream) {
// Automatically decode responses when instructed.
if (!empty($options['decode_content'])) {
$normalizedKeys = \GuzzleHttp\normalize_header_keys($headers);
if (isset($normalizedKeys['content-encoding'])) {
$encoding = $headers[$normalizedKeys['content-encoding']];
if ($encoding[0] == 'gzip' || $encoding[0] == 'deflate') {
$stream = new Psr7\InflateStream(Psr7\stream_for($stream));
// Remove content-encoding header
unset($headers[$normalizedKeys['content-encoding']]);
// Fix content-length header
if (isset($normalizedKeys['content-length'])) {
$length = (int) $stream
->getSize();
if ($length == 0) {
unset($headers[$normalizedKeys['content-length']]);
}
else {
$headers[$normalizedKeys['content-length']] = [
$length,
];
}
}
}
}
}
return [
$stream,
$headers,
];
}