supporting the data_base64
Signed-off-by: Fabio José <fabiojose@gmail.com>
This commit is contained in:
parent
1f8940c8a7
commit
bf4967d30c
|
@ -38,7 +38,11 @@ BinaryHTTPEmitter.prototype.emit = function(cloudevent) {
|
||||||
});
|
});
|
||||||
|
|
||||||
// Set the cloudevent payload
|
// Set the cloudevent payload
|
||||||
_config[Constants.DATA_ATTRIBUTE] = cloudevent.format().data;
|
let formatted = cloudevent.format();
|
||||||
|
let data = formatted.data;
|
||||||
|
data = (formatted.data_base64 ? formatted.data_base64: data);
|
||||||
|
|
||||||
|
_config[Constants.DATA_ATTRIBUTE] = data;
|
||||||
|
|
||||||
// Have extensions?
|
// Have extensions?
|
||||||
var exts = cloudevent.getExtensions();
|
var exts = cloudevent.getExtensions();
|
||||||
|
|
|
@ -135,6 +135,25 @@ describe("HTTP Transport Binding - Version 1.0", () => {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it("the request payload should be correct when event data is binary", () => {
|
||||||
|
let bindata = Uint32Array.from(dataString, (c) => c.codePointAt(0));
|
||||||
|
let expected = asBase64(bindata);
|
||||||
|
let binevent =
|
||||||
|
new Cloudevent(v1.Spec)
|
||||||
|
.type(type)
|
||||||
|
.source(source)
|
||||||
|
.dataContentType("text/plain")
|
||||||
|
.data(bindata)
|
||||||
|
.addExtension(ext1Name, ext1Value)
|
||||||
|
.addExtension(ext2Name, ext2Value);
|
||||||
|
|
||||||
|
return binary.emit(binevent)
|
||||||
|
.then((response) => {
|
||||||
|
expect(response.config.data)
|
||||||
|
.to.equal(expected);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
it("HTTP Header contains 'ce-type'", () => {
|
it("HTTP Header contains 'ce-type'", () => {
|
||||||
return binary.emit(cloudevent)
|
return binary.emit(cloudevent)
|
||||||
.then((response) => {
|
.then((response) => {
|
||||||
|
|
Loading…
Reference in New Issue