private function StreamHandler::checkDecode in Auth0 Single Sign On 8.2
1 call to StreamHandler::checkDecode()
- StreamHandler::createResponse in vendor/guzzlehttp/guzzle/src/Handler/StreamHandler.php
File
- vendor/guzzlehttp/guzzle/src/Handler/StreamHandler.php, line 157
Class
- StreamHandler
- HTTP handler that uses PHP's HTTP stream wrapper.
Namespace
GuzzleHttp\Handler
Code
private function checkDecode(array $options, array $headers, $stream) {
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));
$headers['x-encoded-content-encoding'] = $headers[$normalizedKeys['content-encoding']];
unset($headers[$normalizedKeys['content-encoding']]);
if (isset($normalizedKeys['content-length'])) {
$headers['x-encoded-content-length'] = $headers[$normalizedKeys['content-length']];
$length = (int) $stream
->getSize();
if ($length === 0) {
unset($headers[$normalizedKeys['content-length']]);
}
else {
$headers[$normalizedKeys['content-length']] = [
$length,
];
}
}
}
}
}
return [
$stream,
$headers,
];
}