[Pkg-javascript-commits] [pdf.js] 07/207: Add cache expire time to test server

David Prévot taffit at moszumanska.debian.org
Mon Jul 28 15:36:23 UTC 2014


This is an automated email from the git hooks/post-receive script.

taffit pushed a commit to branch master
in repository pdf.js.

commit 74926995431cf3f0204fb8385d0b1fa45294d84a
Author: fkaelberer <o_0_o at gmx.de>
Date:   Fri May 30 18:42:07 2014 +0200

    Add cache expire time to test server
---
 test/test.js      | 1 +
 test/webserver.js | 7 +++++++
 2 files changed, 8 insertions(+)

diff --git a/test/test.js b/test/test.js
index 1f8ad7b..e27a517 100644
--- a/test/test.js
+++ b/test/test.js
@@ -655,6 +655,7 @@ function startServer() {
   server.host = host;
   server.port = options.port;
   server.root = '..';
+  server.cacheExpirationTime = 3600;
   server.start();
 }
 
diff --git a/test/webserver.js b/test/webserver.js
index ac1e5c6..36a3e4e 100644
--- a/test/webserver.js
+++ b/test/webserver.js
@@ -47,6 +47,7 @@ function WebServer() {
   this.port = 8000;
   this.server = null;
   this.verbose = false;
+  this.cacheExpirationTime = 0;
   this.disableRangeRequests = false;
   this.hooks = {
     'GET': [],
@@ -91,6 +92,7 @@ WebServer.prototype = {
     }
 
     var disableRangeRequests = this.disableRangeRequests;
+    var cacheExpirationTime = this.cacheExpirationTime;
 
     var filePath;
     fs.realpath(path.join(this.root, pathPart), checkFile);
@@ -222,6 +224,11 @@ WebServer.prototype = {
       }
       res.setHeader('Content-Type', contentType);
       res.setHeader('Content-Length', fileSize);
+      if (cacheExpirationTime > 0) {
+        var expireTime = new Date();
+        expireTime.setSeconds(expireTime.getSeconds() + cacheExpirationTime);
+        res.setHeader('Expires', expireTime.toUTCString());
+      }
       res.writeHead(200);
 
       stream.pipe(res);

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/pdf.js.git



More information about the Pkg-javascript-commits mailing list