mirror of
https://github.com/node-red/node-red.git
synced 2023-10-10 13:36:53 +02:00
TRACE should return orig msg in body...
- https://httpwg.org/specs/rfc7231.html#rfc.section.4.3.8
This commit is contained in:
parent
31bd761543
commit
30dca83519
@ -205,18 +205,24 @@ module.exports = function(RED) {
|
|||||||
res.sendStatus(500);
|
res.sendStatus(500);
|
||||||
};
|
};
|
||||||
|
|
||||||
this.callback = function(req,res) {
|
this.callback = function (req, res, next) {
|
||||||
var msgid = RED.util.generateId();
|
const msgid = RED.util.generateId();
|
||||||
|
const resWrap = createResponseWrapper(node, res);
|
||||||
res._msgid = msgid;
|
res._msgid = msgid;
|
||||||
if (node.method.match(/^(post|delete|put|options|patch)$/)) {
|
if (node.method.match(/^(post|delete|put|options|patch)$/)) {
|
||||||
node.send({_msgid:msgid,req:req,res:createResponseWrapper(node,res),payload:req.body});
|
node.send({ _msgid: msgid, req: req, res: resWrap, 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: req, res: resWrap, payload: req.query });
|
||||||
} else if (node.method == "trace") {
|
} else if (node.method == "trace") {
|
||||||
|
// https://httpwg.org/specs/rfc7231.html#rfc.section.4.3.8
|
||||||
res.set('Content-Type', 'message/http')
|
res.set('Content-Type', 'message/http')
|
||||||
node.send({_msgid:msgid,req:req,res:createResponseWrapper(node,res)});
|
// Add REQ string to body (e.g. TRACE / HTTP/1.1)
|
||||||
|
let pl = `TRACE ${req.path} ${req.protocol.toUpperCase()}/${req.httpVersion}\n`;
|
||||||
|
// Add REQ headers to body
|
||||||
|
pl += Object.entries(req.headers).map(e => e.join(": ")).join("\n");
|
||||||
|
node.send({ _msgid: msgid, req: req, res: resWrap, payload: pl });
|
||||||
} else {
|
} else {
|
||||||
node.send({_msgid:msgid,req:req,res:createResponseWrapper(node,res)});
|
node.send({ _msgid: msgid, req: req, res: resWrap });
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user