From 733476f4a1f963b5f5e5a7ef4e7bd40d83d6cd29 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fabio=20Jos=C3=A9?= Date: Sun, 16 Jun 2019 18:45:53 -0300 Subject: [PATCH] Using the commons MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Fabio José --- lib/bindings/http/receiver_binary_0_2.js | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) diff --git a/lib/bindings/http/receiver_binary_0_2.js b/lib/bindings/http/receiver_binary_0_2.js index 3c607e8..b5ab212 100644 --- a/lib/bindings/http/receiver_binary_0_2.js +++ b/lib/bindings/http/receiver_binary_0_2.js @@ -1,4 +1,5 @@ const Constants = require("./constants.js"); +const Commons = require("./commons.js"); const Cloudevent = require("../../cloudevent.js"); const Spec02 = require("../../specs/spec_0_2.js"); @@ -51,16 +52,6 @@ function validate_args(payload, attributes) { } } -function sanity(headers) { - var sanity_headers = JSON.parse(JSON.stringify(headers)); - - for(header in sanity_headers){ - sanity_headers[header.toLowerCase()] = sanity_headers[header]; - } - - return sanity_headers; -} - function Receiver(configuration) { } @@ -70,7 +61,7 @@ Receiver.prototype.check = function(payload, headers) { validate_args(payload, headers); // Clone and low case all headers names - var sanity_headers = sanity(headers); + var sanity_headers = Commons.sanity_and_clone(headers); // Validation Level 1 if(!allowed_content_types @@ -98,7 +89,7 @@ Receiver.prototype.parse = function(payload, headers) { this.check(payload, headers); // Clone and low case all headers names - var sanity_headers = sanity(headers); + var sanity_headers = Commons.sanity_and_clone(headers); var cloudevent = new Cloudevent(Spec02); for(header in setter_reflections) {