Express (node.js) seems to be replacing my content-type with application/json

I've written an express web app route that is essentially a proxy - it pipes the contents of an input stream (a zip file) into the server response's output stream.

I'd like the browser to prompt the user for download or whatever is most appropriate for a zip file. However, when I load this route in a browser, the contents of the input stream (the zip file's contents) show up in the browser window as text, rather than prompting a download. l

This is the code sending the response:

    res.statusCode = 200;
    res.setHeader ('Content-Length', size);
    res.setHeader ('Content-Type', 'application/zip');

    console.log ("content-type is " + res.header('Content-Type'));

    inputStream.pipe (res); 

The console.log statement above outputs "content-type is application/zip".

However, when I examine the request in Chrome's network tab, I see that the response's content-type is "application/json". This implies that express, or something else, is overriding my content-type header, or perhaps has already sent it.

Does anyone know what is changing the content-type on me, and how I could make sure the content-type is the one I set?

Thanks for any help.

You should check the order of the middleware, it's really tricky and can mess things up if they are in the correct order. You can check the correct order here in the Connect webpage