title: Node.js: how to disable chunked transfer-encoding?
body: <p>I'm missing a <code>content-length</code> header on my response from a Node server that I'm piping a .zip file from another location. I've injected a <code>content-length</code> header via the code below, but still it seems the <code>transfer-encoding: chunked</code> is overwriting it somehow.</p>
  
  <h2>Response Headers</h2>
  
  <pre><code>HTTP/1.1 200 OK
  access-control-allow-origin: *
  connection: close
  content-type: application/zip
  date: Mon, 14 Jul 2014 03:47:00 GMT
  etag: "\"eb939974703e14ee9f578642972ed984\""
  last-modified: Sat, 12 Jul 2014 02:15:52 GMT
  server: Apache-Coyote/1.1
  set-cookie: rememberMe=deleteMe; Path=/; Max-Age=0; Expires=Sun, 13-Jul-2014 03:47:00 GMT
  transfer-encoding: chunked
  X-Powered-By: Express
  </code></pre>
  
  <h2>Code</h2>
  
  <pre><code>var request = require('request');
  var express = require('express');
  var async = require('async');
  
  var app = express();
  
  app.get('/:bundle_id?', function(req, res) {
      var bundle_id = req.params.bundle_id;
      bundle_id = bundle_id.replace(/\.zip$/, '');
  
      var url = "https://url....../bundles/" + bundle_id;
  
      async.waterfall([
  
          function(callback) {
              request.get(url, function(req, res, data) {
                  callback(null, JSON.parse(data).entities[0]['file-metadata']['content-length']);
              });
          }
      ], function(err, contentLength) {
  
          request.get({
              url: url,
              headers: {
                  "Accept": "application/zip"
              }
          }).pipe(res);
  
          res.oldWriteHead = res.writeHead;
          res.writeHead = function(statusCode, reasonPhrase, headers) {
              res.header('Content-Length', contentLength);
              res.oldWriteHead(statusCode, reasonPhrase, headers);
          }
      });
  });
  
  app.listen(9000);
  </code></pre>