From de48c1be447098f8f5c24c7a032127c8edb5ea59 Mon Sep 17 00:00:00 2001
From: Nick O'Leary <nick.oleary@gmail.com>
Date: Mon, 11 Jan 2016 22:35:31 +0000
Subject: [PATCH] Wrap http request object to match http response object

---
 nodes/core/io/21-httpin.js | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/nodes/core/io/21-httpin.js b/nodes/core/io/21-httpin.js
index 6b6b0a9daa..ae549e4820 100644
--- a/nodes/core/io/21-httpin.js
+++ b/nodes/core/io/21-httpin.js
@@ -98,7 +98,7 @@ module.exports = function(RED) {
                 wrapper[f] = function() {
                     node.warn(RED._("httpin.errors.deprecated-call",{method:"msg.req."+f}));
                     var result = req[f].apply(req,arguments);
-                    if (result === res) {
+                    if (result === req) {
                         return wrapper;
                     } else {
                         return result;
@@ -177,11 +177,11 @@ module.exports = function(RED) {
                 var msgid = RED.util.generateId();
                 res._msgid = msgid;
                 if (node.method.match(/(^post$|^delete$|^put$|^options$)/)) {
-                    node.send({_msgid:msgid,req:req,res:createResponseWrapper(node,res),payload:req.body});
+                    node.send({_msgid:msgid,req:createRequestWrapper(node,req),res:createResponseWrapper(node,res),payload:req.body});
                 } else if (node.method == "get") {
-                    node.send({_msgid:msgid,req:req,res:createResponseWrapper(node,res),payload:req.query});
+                    node.send({_msgid:msgid,req:createRequestWrapper(node,req),res:createResponseWrapper(node,res),payload:req.query});
                 } else {
-                    node.send({_msgid:msgid,req:req,res:createResponseWrapper(node,res)});
+                    node.send({_msgid:msgid,req:createRequestWrapper(node,req),res:createResponseWrapper(node,res)});
                 }
             };