From c4f4c6b59a8c221b120603cd53d9750198f45ac5 Mon Sep 17 00:00:00 2001 From: Ruben Daniels Date: Mon, 9 Jun 2014 08:27:12 +0000 Subject: [PATCH] Fixes content from the response from node.js being cut off --- lib/http-proxy/common.js | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/lib/http-proxy/common.js b/lib/http-proxy/common.js index 5d10647cf..3b8ddea64 100644 --- a/lib/http-proxy/common.js +++ b/lib/http-proxy/common.js @@ -47,16 +47,20 @@ common.setupOutgoing = function(outgoing, options, req, forward) { outgoing.localAddress = options.localAddress; // - // Remark: If we are false and not upgrading, set the connection: close. This is the right thing to do - // as node core doesn't handle this COMPLETELY properly yet. + // Remark: agent string set to false can break proxies response from node // - if (!outgoing.agent) { - outgoing.headers = outgoing.headers || {}; - if (typeof outgoing.headers.connection !== 'string' - || outgoing.headers.connection.toLowerCase() !== 'upgrade' - ) { outgoing.headers.connection = 'close'; } - } - + if (outgoing.agent === false) + delete outgoing.agent; + // + // Remark: HTTP/1.1 spec says: + // The Connection general-header field allows the sender to specify options + // that are desired for that particular connection and MUST NOT be + // communicated by proxies over further connections. + // See: http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html + // + if (outgoing.headers && outgoing.headers.connection == "close") + delete outgoing.headers.connection; + // // Remark: Can we somehow not use url.parse as a perf optimization? //