From d88e8e484af0580e6607bf531185bed5da2fa2f6 Mon Sep 17 00:00:00 2001 From: Cole Chamberlain Date: Wed, 17 Aug 2016 15:00:40 -0700 Subject: [PATCH 1/2] 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. --- lib/http-proxy/passes/web-outgoing.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/http-proxy/passes/web-outgoing.js b/lib/http-proxy/passes/web-outgoing.js index d8c17a282..f6581b273 100644 --- a/lib/http-proxy/passes/web-outgoing.js +++ b/lib/http-proxy/passes/web-outgoing.js @@ -108,7 +108,9 @@ 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; } ] // <-- From 9ccf4c5ae43b6caaa24323547deebd8e11224130 Mon Sep 17 00:00:00 2001 From: Cole Chamberlain Date: Wed, 31 Aug 2016 07:28:22 -0700 Subject: [PATCH 2/2] Fixed spaces and bracket formatting. --- lib/http-proxy/passes/web-outgoing.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/http-proxy/passes/web-outgoing.js b/lib/http-proxy/passes/web-outgoing.js index f6581b273..b49fbc86b 100644 --- a/lib/http-proxy/passes/web-outgoing.js +++ b/lib/http-proxy/passes/web-outgoing.js @@ -109,8 +109,9 @@ var redirectRegex = /^201|30(1|2|7|8)$/; */ function writeStatusCode(req, res, proxyRes) { res.statusCode = proxyRes.statusCode; - if(proxyRes.statusMessage) - res.statusMessage = proxyRes.statusMessage; + if(proxyRes.statusMessage) { + res.statusMessage = proxyRes.statusMessage; + } } ] // <--