8000 fix: Add Correct Headers to emitted Binary Event (#302) · cloudevents/sdk-javascript@ad0c434 · GitHub
[go: up one dir, main page]

Skip to content

Commit ad0c434

Browse files
authored
fix: Add Correct Headers to emitted Binary Event (#302)
* fix: Binary emitter should add a basic application/json header. fixes #301 Signed-off-by: Lucas Holmquist <lholmqui@redhat.com>
1 parent a7e0aa0 commit ad0c434

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

src/transport/http/binary_emitter.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ export async function emitBinary(event: CloudEvent, options: TransportOptions):
2020
}
2121

2222
async function emit(event: CloudEvent, options: TransportOptions, headers: Headers): Promise<AxiosResponse> {
23-
const contentType: Headers = { [CONSTANTS.HEADER_CONTENT_TYPE]: CONSTANTS.DEFAULT_CE_CONTENT_TYPE };
23+
const contentType: Headers = { [CONSTANTS.HEADER_CONTENT_TYPE]: CONSTANTS.DEFAULT_CONTENT_TYPE };
2424
const config = {
2525
...options,
2626
method: "POST",

test/integration/http_emitter_test.ts

Lines changed: 3 additions & 0 deletions
< 8000 table aria-label="Diff for: test/integration/http_emitter_test.ts" class="tab-size width-full DiffLines-module__tableLayoutFixed--ZmaVx" data-diff-anchor="diff-d56010d92145fb9149442a98ac84b7608e983ef6f2ad64c3f9a68fda370ff505" data-tab-size="8" data-paste-markdown-skip="true" role="grid" style="--line-number-cell-width:40px;--line-number-cell-width-unified:80px">Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import nock from "nock";
44
import CONSTANTS from "../../src/constants";
55

66
const DEFAULT_CE_CONTENT_TYPE = CONSTANTS.DEFAULT_CE_CONTENT_TYPE;
7+
const DEFAULT_CONTENT_TYPE = CONSTANTS.DEFAULT_CONTENT_TYPE;
78

89
import { CloudEvent, Version, Emitter, Protocol, headersFor } from "../../src";
910
import { AxiosResponse } from "axios";
@@ -55,6 +56,7 @@ describe("HTTP Transport Binding Emitter for CloudEvents", () => {
5556
.send(event)
5657
.then((response: AxiosResponse) => {
5758
// A binary message will have a ce-id header
59+
expect(response.data["content-type"]).to.equal(DEFAULT_CONTENT_TYPE);
5860
expect(response.data[CONSTANTS.CE_HEADERS.ID]).to.equal(event.id);
5961
expect(response.data[CONSTANTS.CE_HEADERS.SPEC_VERSION]).to.equal(Version.V1);
6062
// A binary message will have a request body for the data
@@ -82,6 +84,7 @@ describe("HTTP Transport Binding Emitter for CloudEvents", () => {
8284
.then((response: { data: { [k: string]: string } }) => {
8385
// A binary message will have a ce-id header
8486
expect(response.data.customheader).to.equal("value");
87+
expect(response.data["content-type"]).to.equal(DEFAULT_CONTENT_TYPE);
8588
expect(response.data[CONSTANTS.CE_HEADERS.ID]).to.equal(event.id);
8689
expect(response.data[CONSTANTS.CE_HEADERS.SPEC_VERSION]).to.equal(Version.V1);
8790
// A binary message will have a request body for the data

0 commit comments

Comments
 (0)
0