question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

emitter.send() drops datacontenttype header

See original GitHub issue

Not entirely sure on this but I think emitter.send() drops the datacontenttype header.

structured

const event = new CloudEvent({
    id: "4711",
    type: "foo",
    source: "bar",
    datacontenttype: "text/xml",
    data: "<xml>test</xml>"
});

emitter.send(event, { mode: "structured" }).then((response) => {
    console.log(`status: ${response.status} ${response.statusText}`)
}).catch(console.error)

received content-type header : “application/cloudevents+json”

received payload:

{
    "data": "<xml>test</xml>",
    "specversion": "1.0",
    "id": "4711",
    "time": "2020-07-06T06:56:01.645Z",
    "source": "bar",
    "type": "foo"
}

binary

const event = new CloudEvent({
    id: "4711",
    type: "foo",
    source: "bar",
    datacontenttype: "text/xml",
    data: "<xml>test</xml>"
});

emitter.send(event, { mode: "binary" }).then((response) => {
    console.log(`status: ${response.status} ${response.statusText}`)
}).catch(console.error)

received content-type header = “application/json”

I assume the datacontenttype is dropped (not allowed in binary binding). But then the missing value is defaulted to application/json for the content-type header (seems correct from the spec). However, the content-type header should be set to “text/xml” from the given datacontenttype value.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:5 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
lancecommented, Jul 7, 2020

@c-pius yes - the examples are previewing what will be coming in 3.0.0. You can track the release of that in this issue. We made this change to simplify marshaling/unmarshaling of CloudEvent objects, since the specification requires event attributes to be in all lowercase.

0reactions
c-piuscommented, Jul 7, 2020

ah okay, sorry for the confusion. Will this change with the new release however? I was looking at the examples and that is actually where I got the all lowercase datacontenttype from

https://github.com/cloudevents/sdk-javascript/blob/51035dc65b98ce7912d57a78d214612c05c5dc00/examples/typescript-ex/src/index.ts#L9

Read more comments on GitHub >

github_iconTop Results From Across the Web

Apache Kafka Reference Guide - Quarkus
Using the Emitter you are sending messages from your imperative code to reactive messaging. These messages are stored in a queue until they...
Read more >
Writing Kafka Records - SmallRye Reactive Messaging
In the Kafka world, it's often necessary to send records, i.e. a key/value pair. ... withHeaders(new RecordHeaders().add("my-header", "value".
Read more >
Spring SSE (SseEmitter): Flutter Client receiving events only ...
The problem is my Events aren't sent right after method send was called. They all come simultaneously (with same timestamp) to client only...
Read more >
21. Web MVC framework - Spring
The get() method has a further @RequestMapping refinement: it only accepts GET ... In some other thread emitter.send("Hello once"); // and again later...
Read more >
Release Notes for Red Hat build of Quarkus 2.2
In the following example, the hello() method uses a synchronous method ... To achieve this, you must use the emitter.send(instance).
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found