Skip to content
Merged
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/transport/http/binary_emitter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ async function emit(event: CloudEvent, options: Options, headers: Headers): Prom
const config = {
...options,
method: "POST",
headers: { ...contentType, ...headers },
headers: { ...contentType, ...headers, ...options.headers as Headers},
data: asData(event.data, event.datacontenttype as string)
};
return axios.request(config as AxiosRequestConfig);
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 @@ -68,6 +68,17 @@ describe("HTTP Transport Binding Emitter for CloudEvents", () => {
expect(headers[v1Headers.BINARY_HEADERS.TIME]).to.equal(event.time);
});

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.customheader).to.equal("value");
expect(response.data[v1Headers.BINARY_HEADERS.ID]).to.equal(event.id);
expect(response.data[v1Headers.BINARY_HEADERS.SPEC_VERSION]).to.equal(Version.V1);
// A binary message will have a request body for the data
expect(response.data.lunchBreak).to.equal(data.lunchBreak);
}).catch(expect.fail);
});

it("Sends a structured 1.0 CloudEvent if specified", () => {
emitter.send(event, { protocol: Protocol.HTTPStructured })
.then((response: { data: { [k: string]: string | {}, data: { lunchBreak: string } } }) => {
Expand Down