diff --git a/lib/bindings/http/emitter_binary_0_2.js b/lib/bindings/http/emitter_binary_0_2.js index 08f0405..ce6e976 100644 --- a/lib/bindings/http/emitter_binary_0_2.js +++ b/lib/bindings/http/emitter_binary_0_2.js @@ -13,11 +13,11 @@ const Headers02 = { EXTENSIONS_PREFIX : "ce-" }; -const required_attributes = []; -required_attributes.push(Headers02.TYPE); -required_attributes.push(Headers02.SPEC_VERSION); -required_attributes.push(Headers02.SOURCE); -required_attributes.push(Headers02.ID); +const required_headers = []; +required_headers.push(Headers02.TYPE); +required_headers.push(Headers02.SPEC_VERSION); +required_headers.push(Headers02.SOURCE); +required_headers.push(Headers02.ID); function validate_args(payload, attributes) { if(!payload){ @@ -45,18 +45,24 @@ function HTTPBinary02(configuration){ Constants.MIME_CE_JSON + "; charset=" + Constants.CHARSET_DEFAULT; } -HTTPBinary02.prototype.check = function(payload, attributes) { +HTTPBinary02.prototype.check = function(payload, headers) { // Validation Level 0 - validate_args(payload, attributes); + validate_args(payload, headers); // Validation Level 1 - for(i in required_attributes){ - if(!attributes[required_attributes[i]]){ - throw {message: "header '" + required_attributes[i] + "' not found"}; + for(i in required_headers){ + if(!headers[required_headers[i]]){ + throw {message: "header '" + required_headers[i] + "' not found"}; } } + // No erros! Its contains the minimum required attributes +} +HTTPBinary02.prototype.parse = function(payload, headers) { + this.check(payload, headers); + + } HTTPBinary02.prototype.emit = function(cloudevent){