From acbb6e3e10ea768d9c23f271dcf9019bfeae8b84 Mon Sep 17 00:00:00 2001 From: lucaswadedavis Date: Mon, 19 Dec 2016 14:22:41 -0800 Subject: [PATCH] Set content length. --- server.js | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/server.js b/server.js index 6be73ec..94be89d 100644 --- a/server.js +++ b/server.js @@ -45,24 +45,30 @@ app.get('/', function(req, res) { var width = 400; var seed = uuid(); var canvas = composeImage(width, width, seed); + var buffer = canvas.toBuffer(); + res.set('Content-length', buffer.length); res.type('png'); - res.end(canvas.toBuffer(), 'binary'); + res.end(buffer, 'binary'); }); app.get('/:width', function(req, res) { var width = parseInt(req.params.width) || 400; var seed = uuid(); var canvas = composeImage(width, width, seed); + var buffer = canvas.toBuffer(); + res.set('Content-length', buffer.length); res.type('png'); - res.end(canvas.toBuffer(), 'binary'); + res.end(buffer, 'binary'); }); app.get('/:width/:seed', function(req, res) { var width = parseInt(req.params.width) || 400; var seed = sanitize(req.params.seed) || uuid(); var canvas = composeImage(width, width, seed); + var buffer = canvas.toBuffer(); + res.set('Content-length', buffer.length); res.type('png'); - res.end(canvas.toBuffer(), 'binary'); + res.end(buffer, 'binary'); }); app.listen(process.env.PORT || 3000);