Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Add Correct Headers to emitted Binary Event #302

Merged
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 @@ -20,7 +20,7 @@ export async function emitBinary(event: CloudEvent, options: TransportOptions):
}

async function emit(event: CloudEvent, options: TransportOptions, headers: Headers): Promise<AxiosResponse> {
const contentType: Headers = { [CONSTANTS.HEADER_CONTENT_TYPE]: CONSTANTS.DEFAULT_CE_CONTENT_TYPE };
const contentType: Headers = { [CONSTANTS.HEADER_CONTENT_TYPE]: CONSTANTS.DEFAULT_CONTENT_TYPE };
const config = {
...options,
method: "POST",
Expand Down
3 changes: 3 additions & 0 deletions test/integration/http_emitter_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import nock from "nock";
import CONSTANTS from "../../src/constants";

const DEFAULT_CE_CONTENT_TYPE = CONSTANTS.DEFAULT_CE_CONTENT_TYPE;
const DEFAULT_CONTENT_TYPE = CONSTANTS.DEFAULT_CONTENT_TYPE;

import { CloudEvent, Version, Emitter, Protocol, headersFor } from "../../src";
import { AxiosResponse } from "axios";
Expand Down Expand Up @@ -55,6 +56,7 @@ describe("HTTP Transport Binding Emitter for CloudEvents", () => {
.send(event)
.then((response: AxiosResponse) => {
// A binary message will have a ce-id header
expect(response.data["content-type"]).to.equal(DEFAULT_CONTENT_TYPE);
expect(response.data[CONSTANTS.CE_HEADERS.ID]).to.equal(event.id);
expect(response.data[CONSTANTS.CE_HEADERS.SPEC_VERSION]).to.equal(Version.V1);
// A binary message will have a request body for the data
Expand Down Expand Up @@ -82,6 +84,7 @@ describe("HTTP Transport Binding Emitter for CloudEvents", () => {
.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["content-type"]).to.equal(DEFAULT_CONTENT_TYPE);
expect(response.data[CONSTANTS.CE_HEADERS.ID]).to.equal(event.id);
expect(response.data[CONSTANTS.CE_HEADERS.SPEC_VERSION]).to.equal(Version.V1);
// A binary message will have a request body for the data
Expand Down