server = $server; $this->server->on('afterMethod:PROPFIND', [$this, 'compressResponse'], 100); } public function compressResponse(Request $request, Response $response) { $header = $request->getHeader('Accept-Encoding'); if ($header === null) { return $response; } if (str_contains($header, 'gzip')) { $body = $response->getBody(); if (is_string($body)) { $response->setHeader('Content-Encoding', 'gzip'); $response->setBody(gzencode($body)); } } return $response; } }