Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/lib/bindings/http/emitter_binary.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ class BinaryHTTPEmitter {
* @returns {Promise} Promise with an eventual response from the receiver
*/
async emit(options, cloudevent) {
const config = { ...options, ...defaults };
const config = { ...defaults, ...options };
const headers = config[HEADERS];

this.headerParserMap.forEach((parser, getterName) => {
Expand Down
11 changes: 11 additions & 0 deletions test-ts/http_emitter_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,17 @@ describe("HTTP Transport Binding Emitter for CloudEvents", () => {
}).catch(expect.fail);
});

it("Sends a binary CloudEvent with Custom Headers", () => {
emitter.send(event, { headers: { customheader: "value" } }).then((response: { data: { [k: string]: string } }) => {
// A binary message will have a ce-id header
expect(response.data.headers.customheader).to.equal("value");
expect(response.data[BINARY_HEADERS_1.ID]).to.equal(event.id);
expect(response.data[BINARY_HEADERS_1.SPEC_VERSION]).to.equal(SPEC_V1);
// A binary message will have a request body for the data
expect(response.data.lunchBreak).to.equal(data.lunchBreak);
}).catch(expect.fail);
});

it("Provides the HTTP headers for a binary event", () => {
const headers = HTTPEmitter.headers(event);
expect(headers[BINARY_HEADERS_1.TYPE]).to.equal(event.type);
Expand Down