From 8b5b8a673767b1a37948bfd22a7c934353288560 Mon Sep 17 00:00:00 2001 From: Aydin Date: Tue, 23 Jan 2018 12:40:08 +0100 Subject: [PATCH 1/2] Update common.js Add method parameter to options for overriding the proxy-outgoing HTTP-method --- lib/http-proxy/common.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/http-proxy/common.js b/lib/http-proxy/common.js index aa9700234..6f0fcbcab 100644 --- a/lib/http-proxy/common.js +++ b/lib/http-proxy/common.js @@ -40,7 +40,7 @@ common.setupOutgoing = function(outgoing, options, req, forward) { function(e) { outgoing[e] = options[forward || 'target'][e]; } ); - outgoing.method = req.method; + outgoing.method = options.method || req.method; outgoing.headers = extend({}, req.headers); if (options.headers){ From 0e96903081f3703fc46f7e6572a0ad582d5007f4 Mon Sep 17 00:00:00 2001 From: Aydin Date: Wed, 24 Jan 2018 09:44:59 +0100 Subject: [PATCH 2/2] Update README.md --- README.md | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/README.md b/README.md index 40367e111..cabedc5fe 100644 --- a/README.md +++ b/README.md @@ -16,6 +16,27 @@ node-http-proxy websockets. It is suitable for implementing components such as reverse proxies and load balancers. +### Fork details +This fork offers the option for overriding the proxy-outgoing HTTP-method. + +Example usage: + +`var server = http.createServer(function(req, res) { + // You can define here your custom logic to handle the request + // and then proxy the request. + proxy.web(req, res, { target: 'http://127.0.0.1:9200', method: 'GET' }); + console.log("req: " + req); + console.log("res: " + res); +});` + +You could also wrap it into a conditional statement like: + +`if ( req.method == "POST" ) { + proxy.web ... +}` + +https://github.com/nodejitsu/node-http-proxy/pull/1231 + ### Table of Contents * [Installation](#installation) * [Upgrading from 0.8.x ?](#upgrading-from-08x-)