Index: work/remote/web/README =================================================================== --- work/remote/web/README (revision 5953) +++ work/remote/web/README (revision 5954) @@ -38,13 +38,13 @@ Drawing Test -Currently test files for the remote protocol (the ones with .remote -extension) are loaded from ./testdata. gzipped files are not supported. +Test files for the remote protocol (the ones with .remote.gz extension) +are loaded from trunk/tests/RTT/ref. To specify another test file for the drawing test you should edit testclient/draw.js. Change the following function call near line 7: -drawRemoteFile("../testdata/netlist.pcb.remote"); +drawRemoteFile("../testdata/netlist.remote.gz"); For more info read testserver/README and testclient/README. Index: work/remote/web/testclient/draw.js =================================================================== --- work/remote/web/testclient/draw.js (revision 5953) +++ work/remote/web/testclient/draw.js (revision 5954) @@ -6,8 +6,8 @@ var draw = require("../client/scripts/draw"); -drawRemoteFile("../testdata/netlist.pcb.remote"); -//drawRemoteFile("../testdata/line_normal.pcb.remote"); +drawRemoteFile("../testdata/netlist.remote.gz"); +//drawRemoteFile("../testdata/line_normal.remote.gz"); function drawRemoteFile(url) { Index: work/remote/web/testserver/app.js =================================================================== --- work/remote/web/testserver/app.js (revision 5953) +++ work/remote/web/testserver/app.js (revision 5954) @@ -3,7 +3,7 @@ var morgan = require('morgan'); var app = express(); -var expressWs = require('express-ws')(app); +var expressWs = require('express-ws')(app); // registers app.ws var serverecho; var clientecho; @@ -24,7 +24,7 @@ // this will serve static files app.use("/", express.static("../client")); app.use("/test", express.static("../testclient")); -app.use("/testdata", express.static("../testdata")); +app.use("/testdata", gzipDirectory("../../../../trunk/tests/RTT/ref")); app.use("/protocol", express.static("../protocol")); // this will log http requests @@ -58,3 +58,23 @@ var server = app.listen(process.env.port || 3000, function () { console.log('testserver listening on port', server.address().port); }); + +// middleware for serving gzipped files +// note: this would be too slow in production code but it will do it for test +function gzipDirectory(localPath) { + return function (req, res) { + var path = req.path + ".gz"; + if (/\.gz$/.test(req.path)) { + if (req.acceptsEncodings("gzip")) { + // automatic gunzip on client side + res.set('Content-Encoding', 'gzip'); + res.sendFile(req.path, { root: localPath }); + } else { + res.status(415).send("gzip support required in the browser"); + } + } else { + // send as normal static file + res.sendFile(req.path, { root: localPath }); + } + }; +}