mirror of
https://github.com/node-red/node-red.git
synced 2023-10-10 13:36:53 +02:00
Merge pull request #3908 from node-red/add-httpheaders
Ensure msg.req.headers is enumerable
This commit is contained in:
commit
2a49e7c8ef
@ -46,7 +46,7 @@ module.exports = function(RED) {
|
|||||||
isText = true;
|
isText = true;
|
||||||
} else if (parsedType.type !== "application") {
|
} else if (parsedType.type !== "application") {
|
||||||
isText = false;
|
isText = false;
|
||||||
} else if ((parsedType.subtype !== "octet-stream")
|
} else if ((parsedType.subtype !== "octet-stream")
|
||||||
&& (parsedType.subtype !== "cbor")
|
&& (parsedType.subtype !== "cbor")
|
||||||
&& (parsedType.subtype !== "x-protobuf")) {
|
&& (parsedType.subtype !== "x-protobuf")) {
|
||||||
checkUTF = true;
|
checkUTF = true;
|
||||||
@ -200,6 +200,15 @@ module.exports = function(RED) {
|
|||||||
this.callback = function(req,res) {
|
this.callback = function(req,res) {
|
||||||
var msgid = RED.util.generateId();
|
var msgid = RED.util.generateId();
|
||||||
res._msgid = msgid;
|
res._msgid = msgid;
|
||||||
|
// Since Node 15, req.headers are lazily computed and the property
|
||||||
|
// marked as non-enumerable.
|
||||||
|
// That means it doesn't show up in the Debug sidebar.
|
||||||
|
// This redefines the property causing it to be evaluated *and*
|
||||||
|
// marked as enumerable again.
|
||||||
|
Object.defineProperty(req, 'headers', {
|
||||||
|
value: req.headers,
|
||||||
|
enumerable: true
|
||||||
|
})
|
||||||
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:createResponseWrapper(node,res),payload:req.body});
|
||||||
} else if (node.method == "get") {
|
} else if (node.method == "get") {
|
||||||
|
Loading…
Reference in New Issue
Block a user