sdk-javascript/lib/bindings/http
Lance Ball 72a87dfb2d
fix: ensure binary events can handle no content-type header (#134)
* fix: ensure binary events can handle no content-type header

The fix provided in https://github.com/cloudevents/sdk-javascript/pull/118
only included tests for `receiver.check()`, and the change in that
case was to add the `application/json` content type to the cleansed
headers if to type was specified.

However, `receiver.parse()` did not receive the benefit of this change. It
calls `this.check()` but then sanitizes the original headers again, and the
missing content-type was not re-inserted into the newly sanitized headers.

This commit, modifies the code so that `receiver.check()` does not insert
the content-type, but does allow the validation check to pass if no
content-type header exists. When `receiver.parse()` is called, and the
headers are sanitized again - and this time used to look up parser implementation,
the default `application/json` content-is applied if no content-type header
exists.

I've also removed a redundant call to `receiver.check()` in receiver_binary_1.js
and simplified the usage of `Constants` in the test.

Signed-off-by: Lance Ball <lball@redhat.com>

* chore: clean up header sniffing

Signed-off-by: Lance Ball <lball@redhat.com>
2020-05-08 23:37:10 -04:00
..
commons.js src: add eslint configuration and npm script 2020-04-22 10:15:05 -04:00
constants.js fix: protects the consts from being changed in other parts of the code. 2020-04-30 12:19:24 -03:00
emitter_binary.js src: add eslint configuration and npm script 2020-04-22 10:15:05 -04:00
emitter_binary_0_3.js src: add eslint configuration and npm script 2020-04-22 10:15:05 -04:00
emitter_binary_1.js src: add eslint configuration and npm script 2020-04-22 10:15:05 -04:00
emitter_structured.js src: add eslint configuration and npm script 2020-04-22 10:15:05 -04:00
http_receiver.js feat: expose a mode and version agnostic event receiver (#120) 2020-05-06 13:25:16 -04:00
receiver_binary.js fix: ensure binary events can handle no content-type header (#134) 2020-05-08 23:37:10 -04:00
receiver_binary_0_3.js src: add eslint configuration and npm script 2020-04-22 10:15:05 -04:00
receiver_binary_1.js fix: ensure binary events can handle no content-type header (#134) 2020-05-08 23:37:10 -04:00
receiver_structured.js feat: use CloudEvents not cloudevents everywhere (#101) 2020-04-30 16:14:13 -07:00
receiver_structured_0_3.js src: add eslint configuration and npm script 2020-04-22 10:15:05 -04:00
receiver_structured_1.js src: add eslint configuration and npm script 2020-04-22 10:15:05 -04:00
unmarshaller.js feat(unmarshaller)!: remove asynchronous 0.3 unmarshaller API (#126) 2020-05-06 20:05:10 -04:00
unmarshaller_0_3.js src: add eslint configuration and npm script 2020-04-22 10:15:05 -04:00