Skip to content

Commit d8fb344

Browse files
cchamberlainjcrugzz
authored andcommitted
Fix for Reason-Phrase being overwritten on proxy response. (#1051)
* 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.
1 parent 1e52f66 commit d8fb344

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

lib/http-proxy/passes/web-outgoing.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,10 @@ var redirectRegex = /^201|30(1|2|7|8)$/;
108108
* @api private
109109
*/
110110
function writeStatusCode(req, res, proxyRes) {
111-
res.writeHead(proxyRes.statusCode);
111+
res.statusCode = proxyRes.statusCode;
112+
if(proxyRes.statusMessage) {
113+
res.statusMessage = proxyRes.statusMessage;
114+
}
112115
}
113116

114117
] // <--

0 commit comments

Comments
 (0)