[Pkg-javascript-commits] [pdf.js] 122/161: Disables range requests for chrome windows during testing

David Prévot taffit at moszumanska.debian.org
Sat Apr 19 14:16:37 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 cc0c0747b5b19e03f13000be6fdae0cc183abfc3
Author: Yury Delendik <ydelendik at mozilla.com>
Date:   Tue Mar 25 14:53:40 2014 -0500

    Disables range requests for chrome windows during testing
---
 test/webserver.js | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/test/webserver.js b/test/webserver.js
index 670206d..b854619 100644
--- a/test/webserver.js
+++ b/test/webserver.js
@@ -64,6 +64,7 @@ WebServer.prototype = {
     this.server = null;
   },
   _handler: function (req, res) {
+    var agent = req.headers['user-agent'];
     var url = req.url;
     var urlParts = /([^?]*)((?:\?(.*))?)/.exec(url);
     var pathPart = decodeURI(urlParts[1]), queryPart = urlParts[3];
@@ -88,6 +89,9 @@ WebServer.prototype = {
       return;
     }
 
+    // disables range requests for chrome windows -- locks during testing
+    var disableRangeRequests = /Windows.*?Chrom/i.test(agent);
+
     var filePath;
     fs.realpath(path.join(this.root, pathPart), checkFile);
 
@@ -127,7 +131,7 @@ WebServer.prototype = {
       }
 
       var range = req.headers['range'];
-      if (range) {
+      if (range && !disableRangeRequests) {
         var rangesMatches = /^bytes=(\d+)\-(\d+)?/.exec(range);
         if (!rangesMatches) {
           res.writeHead(501);
@@ -214,7 +218,9 @@ WebServer.prototype = {
       var ext = path.extname(filePath).toLowerCase();
       var contentType = mimeTypes[ext] || defaultMimeType;
 
-      res.setHeader('Accept-Ranges', 'bytes');
+      if (!disableRangeRequests) {
+        res.setHeader('Accept-Ranges', 'bytes');
+      }
       res.setHeader('Content-Type', contentType);
       res.setHeader('Content-Length', fileSize);
       res.writeHead(200);

-- 
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