diff options
author | Christoph Wurst <ChristophWurst@users.noreply.github.com> | 2018-08-21 12:52:32 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-08-21 12:52:32 +0300 |
commit | d5b3a6ef4e4d6f2745cf6bbd7fc13943122ad562 (patch) | |
tree | e3e4a2858f74c7a5eb1322f753d386f16d900fd9 /lib | |
parent | ad17db0198a4900e4631e5bfcccd5614b254c032 (diff) | |
parent | a56dd591f25f8049aca5791d4dce5372ec0eb78b (diff) |
Merge pull request #1035 from nextcloud/enhancement/proxydownloadresponse-caching
Use CacheHeaders trait for the ProxyDownloadResponse class
Diffstat (limited to 'lib')
-rw-r--r-- | lib/Http/ProxyDownloadResponse.php | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/lib/Http/ProxyDownloadResponse.php b/lib/Http/ProxyDownloadResponse.php index b5da41d75..c8af04ee3 100644 --- a/lib/Http/ProxyDownloadResponse.php +++ b/lib/Http/ProxyDownloadResponse.php @@ -25,10 +25,14 @@ declare(strict_types=1); namespace OCA\Mail\Http; use DateTime; +use OC; use OCP\AppFramework\Http\DownloadResponse; +use OCP\AppFramework\Utility\ITimeFactory; class ProxyDownloadResponse extends DownloadResponse { + use CacheHeaders; + /** @var string */ private $content; @@ -47,10 +51,10 @@ class ProxyDownloadResponse extends DownloadResponse { $this->content = $content; - $expires = new DateTime('now + 11 months'); - $this->addHeader('Expires', $expires->format(DateTime::RFC1123)); - $this->addHeader('Cache-Control', 'private'); - $this->addHeader('Pragma', 'cache'); + $time = OC::$server->query(ITimeFactory::class); + $now = (new DateTime('now'))->getTimestamp(); + $expires = (new DateTime('now + 11 months'))->getTimestamp(); + $this->setCacheHeaders($expires - $now, $time); } /** |