Skip to content

Commit

Permalink
Fix for Reason-Phrase being overwritten on proxy response. (#1051)
Browse files Browse the repository at this point in the history
* Fix for Reason-Phrase being overwritten on proxy response.

Calling res.writeHead has the side effect of defaulting the Reason-Phrase to default ones.  I'm using Reason-Phrase codes to sub-route api responses and they were all being reset.  This change only sets the statusMessage (Reason-Phrase) if it exists on the proxyRes and is successfully passing it through in my tests.

* Fixed spaces and bracket formatting.
  • Loading branch information
cchamberlain authored and jcrugzz committed Sep 13, 2016
1 parent 1e52f66 commit d8fb344
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion lib/http-proxy/passes/web-outgoing.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,10 @@ var redirectRegex = /^201|30(1|2|7|8)$/;
* @api private
*/
function writeStatusCode(req, res, proxyRes) {
res.writeHead(proxyRes.statusCode);
res.statusCode = proxyRes.statusCode;
if(proxyRes.statusMessage) {
res.statusMessage = proxyRes.statusMessage;
}
}

] // <--
Expand Down

0 comments on commit d8fb344

Please sign in to comment.