diff --git a/snappymail/v/0.0.0/app/libraries/snappymail/http/response.php b/snappymail/v/0.0.0/app/libraries/snappymail/http/response.php index 18411512f..676b5c126 100644 --- a/snappymail/v/0.0.0/app/libraries/snappymail/http/response.php +++ b/snappymail/v/0.0.0/app/libraries/snappymail/http/response.php @@ -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 */