mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-10-24 22:25:09 +03:00
Don't inflate http response by default
This commit is contained in:
parent
0204ca48ee
commit
b5c1be34c2
1 changed files with 15 additions and 10 deletions
|
|
@ -39,23 +39,28 @@ class Response
|
||||||
$this->request_uri = $request_uri;
|
$this->request_uri = $request_uri;
|
||||||
$this->final_uri = $request_uri;
|
$this->final_uri = $request_uri;
|
||||||
$this->status = (int) $status;
|
$this->status = (int) $status;
|
||||||
if (\function_exists('gzinflate') && isset($this->headers['content-encoding'])
|
|
||||||
&& (false !== \stripos($this->headers['content-encoding'], 'gzip'))) {
|
|
||||||
$this->body = \gzinflate(\substr($body, 10, -4));
|
|
||||||
if (false === $this->body) {
|
|
||||||
$err = \error_get_last() ?: ['message' => 'gzinflate failed'];
|
|
||||||
throw new \RuntimeException("{$err['message']} for {$request_uri}");
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
$this->body = $body;
|
$this->body = $body;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
function __get($k)
|
function __get($k)
|
||||||
{
|
{
|
||||||
return \property_exists($this, $k) ? $this->$k : null;
|
return \property_exists($this, $k) ? $this->$k : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function decoded()/*: string|false*/
|
||||||
|
{
|
||||||
|
$body = $this->body;
|
||||||
|
if (\function_exists('gzinflate') && isset($this->headers['content-encoding'])
|
||||||
|
&& (false !== \stripos($this->headers['content-encoding'], 'gzip'))) {
|
||||||
|
$body = \gzinflate(\substr($body, 10, -4));
|
||||||
|
if (false === $body) {
|
||||||
|
$err = \error_get_last() ?: ['message' => 'gzinflate failed'];
|
||||||
|
throw new \RuntimeException("{$err['message']} for {$request_uri}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return $body;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* returns string, array or null
|
* returns string, array or null
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue