-
Notifications
You must be signed in to change notification settings - Fork 69
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
Emit Binary, but receives Structured #301
Comments
Edit: Well, I don't know how the emitter works, but I would assume we want the user to specify whether to emit binary or structured. The code above seems fine. It seems like we don't specify that message mode when emitting? |
The default with no options is binary, which is here: https://github.com/cloudevents/sdk-javascript/blob/master/src/transport/emitter.ts#L48 I think not specifying is ok, as long as we document that it defaults to something.
I guess i'm not familiar enough with the spec to know if the headers we add should be different than what we do currently for binary mode |
Hmm - looks strange
The content type header here indicates a structured event. However, the inclusion of all of the This appears to be a bug. This line should be: const contentType: Headers = { [CONSTANTS.HEADER_CONTENT_TYPE]: CONSTANTS.DEFAULT_CONTENT_TYPE }; Very strange that this hasn't been caught in tests.... |
Follow up... In our |
LOL, just wrote that:
And glad this is a bug and i'm not going crazy :) |
Also, is there a place in the spec, that says which headers are suppose to go with which mode? |
assigning to myself to fix if no one minds |
|
I don't think we need to call |
yup, was just illustrating why we never picked up the issue until now |
fixes cloudevents#301 Signed-off-by: Lucas Holmquist <lholmqui@redhat.com>
Describe the Bug
I was playing around with a small example where i Emit a binary cloud event. something like this:
Then i have a basic express.js application running on port 3000 with the route
cloudeventy
to receive the event coming in, which looks similar to this:However, I get an error saying that "Cannot read property specversion of undefned".
I also console logged out my request headers too.
When i step through the code on the receiving end, it treats it as a structured event, not a binary event, even though that was how it was sent.
There is code to determine the mode, that parses the content-type header. https://github.com/cloudevents/sdk-javascript/blob/master/src/transport/receiver.ts#L66 and if it sees
application/cloudevents
then it says it is a "structured" event. The problem is that both the structured and binary emitters add the same content-type header.Binary Emitter Headers: https://github.com/cloudevents/sdk-javascript/blob/master/src/transport/http/binary_emitter.ts#L23
Structured Emitter Headers: https://github.com/cloudevents/sdk-javascript/blob/master/src/transport/http/structured_emitter.ts#L8
It seems that the check for "Binary Headers" should happen first, unless the headers are wrong for the binary version
Extra Context:
These code examples i gave above i think would make a good example, since we don't have an emitter example yet
@lance @grant thoughts?
The text was updated successfully, but these errors were encountered: