From e8c890d361742b0e73442ffe4d80fefd9d774356 Mon Sep 17 00:00:00 2001 From: Lucas Holmquist Date: Wed, 5 Aug 2020 18:21:23 -0400 Subject: [PATCH 1/3] squash: update test to fail Signed-off-by: Lucas Holmquist --- test/integration/http_emitter_test.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/test/integration/http_emitter_test.ts b/test/integration/http_emitter_test.ts index b5f211be..7703d4e9 100644 --- a/test/integration/http_emitter_test.ts +++ b/test/integration/http_emitter_test.ts @@ -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"; @@ -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 From 51c67e3b25721b8e0f71242bbe2b74e8d235a2a4 Mon Sep 17 00:00:00 2001 From: Lucas Holmquist Date: Wed, 5 Aug 2020 18:33:59 -0400 Subject: [PATCH 2/3] fix: Binary emitter should add a basic application/json header. fixes #301 Signed-off-by: Lucas Holmquist --- src/transport/http/binary_emitter.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/transport/http/binary_emitter.ts b/src/transport/http/binary_emitter.ts index 1ea8eb03..20f51662 100644 --- a/src/transport/http/binary_emitter.ts +++ b/src/transport/http/binary_emitter.ts @@ -20,7 +20,7 @@ export async function emitBinary(event: CloudEvent, options: TransportOptions): } async function emit(event: CloudEvent, options: TransportOptions, headers: Headers): Promise { - 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", From e49761efb6f182f1401c23496b03a517a0dd4c37 Mon Sep 17 00:00:00 2001 From: Lucas Holmquist Date: Wed, 5 Aug 2020 18:39:16 -0400 Subject: [PATCH 3/3] squash: test a couple more places Signed-off-by: Lucas Holmquist --- test/integration/http_emitter_test.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/test/integration/http_emitter_test.ts b/test/integration/http_emitter_test.ts index 7703d4e9..62f0f5ca 100644 --- a/test/integration/http_emitter_test.ts +++ b/test/integration/http_emitter_test.ts @@ -84,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