From 77bad8d07f3c707446a5414d0a1e658c2752f8cf Mon Sep 17 00:00:00 2001 From: Julia Huang Date: Tue, 11 Jun 2019 14:22:47 -0700 Subject: [PATCH] Make a copy of configuration being passed in - tests should now be passing --- lib/bindings/http/binary_0_1.js | 2 +- lib/bindings/http/binary_0_2.js | 2 +- lib/bindings/http/structured_0_1.js | 3 ++- lib/bindings/http/structured_0_2.js | 2 +- 4 files changed, 5 insertions(+), 4 deletions(-) diff --git a/lib/bindings/http/binary_0_1.js b/lib/bindings/http/binary_0_1.js index 5bac97bd..0619a626 100644 --- a/lib/bindings/http/binary_0_1.js +++ b/lib/bindings/http/binary_0_1.js @@ -1,7 +1,7 @@ var axios = require("axios"); function HTTPBinary(configuration){ - this.config = configuration; + this.config = JSON.parse(JSON.stringify(configuration)); this.config["headers"] = { "Content-Type":"application/cloudevents+json; charset=utf-8" diff --git a/lib/bindings/http/binary_0_2.js b/lib/bindings/http/binary_0_2.js index 8d249e53..3efa607f 100644 --- a/lib/bindings/http/binary_0_2.js +++ b/lib/bindings/http/binary_0_2.js @@ -2,7 +2,7 @@ var axios = require("axios"); var empty = require("is-empty"); function HTTPBinary(configuration){ - this.config = configuration; + this.config = JSON.parse(JSON.stringify(configuration)); this.config["headers"] = { "Content-Type":"application/cloudevents+json; charset=utf-8" diff --git a/lib/bindings/http/structured_0_1.js b/lib/bindings/http/structured_0_1.js index 65c65309..cf352820 100644 --- a/lib/bindings/http/structured_0_1.js +++ b/lib/bindings/http/structured_0_1.js @@ -1,7 +1,7 @@ var axios = require("axios"); function HTTPStructured(configuration){ - this.config = configuration; + this.config = JSON.parse(JSON.stringify(configuration)); this.config["headers"] = { "Content-Type":"application/cloudevents+json; charset=utf-8" @@ -13,6 +13,7 @@ HTTPStructured.prototype.emit = function(cloudevent){ // Create new request object var _config = JSON.parse(JSON.stringify(this.config)); + // Set the cloudevent payload _config["data"] = cloudevent.format(); diff --git a/lib/bindings/http/structured_0_2.js b/lib/bindings/http/structured_0_2.js index 65c65309..fd459560 100644 --- a/lib/bindings/http/structured_0_2.js +++ b/lib/bindings/http/structured_0_2.js @@ -1,7 +1,7 @@ var axios = require("axios"); function HTTPStructured(configuration){ - this.config = configuration; + this.config = JSON.parse(JSON.stringify(configuration)); this.config["headers"] = { "Content-Type":"application/cloudevents+json; charset=utf-8"