mirror of
https://github.com/node-red/node-red.git
synced 2023-10-10 13:36:53 +02:00
Wrap http request object to match http response object
This commit is contained in:
parent
0786ec4b66
commit
de48c1be44
@ -98,7 +98,7 @@ module.exports = function(RED) {
|
|||||||
wrapper[f] = function() {
|
wrapper[f] = function() {
|
||||||
node.warn(RED._("httpin.errors.deprecated-call",{method:"msg.req."+f}));
|
node.warn(RED._("httpin.errors.deprecated-call",{method:"msg.req."+f}));
|
||||||
var result = req[f].apply(req,arguments);
|
var result = req[f].apply(req,arguments);
|
||||||
if (result === res) {
|
if (result === req) {
|
||||||
return wrapper;
|
return wrapper;
|
||||||
} else {
|
} else {
|
||||||
return result;
|
return result;
|
||||||
@ -177,11 +177,11 @@ module.exports = function(RED) {
|
|||||||
var msgid = RED.util.generateId();
|
var msgid = RED.util.generateId();
|
||||||
res._msgid = msgid;
|
res._msgid = msgid;
|
||||||
if (node.method.match(/(^post$|^delete$|^put$|^options$)/)) {
|
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") {
|
} 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 {
|
} else {
|
||||||
node.send({_msgid:msgid,req:req,res:createResponseWrapper(node,res)});
|
node.send({_msgid:msgid,req:createRequestWrapper(node,req),res:createResponseWrapper(node,res)});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user