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,16 +39,7 @@ class Response
|
|||
$this->request_uri = $request_uri;
|
||||
$this->final_uri = $request_uri;
|
||||
$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)
|
||||
|
|
@ -56,6 +47,20 @@ class Response
|
|||
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
|
||||
*/
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue