Description
While using the #727 example code to get NTLM working behind node-http-proxy, I saw an error on the second response from my node-sspi server.
In line 85 of http-outgoing.js an error was thrown that looked like this:
_http_outgoing.js:342
throw new Error('value
required in setHeader("' + name + '", value).');
^Error:
value
required in setHeader("www-authenticate", value).
at ServerResponse.OutgoingMessage.setHeader (_http_outgoing.js:342:11)
I created a net server that simply piped everything from the http-proxy to my app and another that piped everything from the browser to http-proxy and also outputted everything to stdout so I could compare what was going into and out of http-proxy. And when that error is thrown the header www-authenticate is not returned from node-sspi. It looks like it is somehow cached or held in a reused object inside of node-http-proxy.
My simple fix for now is to change line 85 of web-outgoing.js to: if(proxyRes.headers[key]){ res.setHeader(key, proxyRes.headers[key]);}
but I'm not sure if that is the best solution since http-proxy is trying to set a header for which nothing was passed in.