Skip to content

Commit 2ca5aaa

Browse files
committed
allow for content-less via binary mode for CloudEventBinding
1 parent 0b7f66b commit 2ca5aaa

2 files changed

Lines changed: 9 additions & 1 deletion

File tree

samples/CloudNative.CloudEvents.AspNetCoreSample/CloudEventBinding.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ public static async ValueTask<CloudEventBinding> BindAsync(HttpContext context,
2626
// types such as "text/xml" could still be parsed with the current JsonEventFormatter,
2727
// but it's just not making it strongly typed, or anything structured (XmlNode).
2828
// Depending on your use-case, it may or may not be desirable to allow that.
29-
if (!request.HasJsonContentType())
29+
if (request.ContentLength != 0 && !request.HasJsonContentType())
3030
{
3131
return new CloudEventBinding
3232
{

samples/CloudNative.CloudEvents.AspNetCoreSample/CloudNative.CloudEvents.AspNetCoreSample.http

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,14 @@ CE-Id: "{{$guid}}"
2828
"message": "Hello world!"
2929
}
3030

31+
### Send content-less via Binary mode
32+
33+
POST {{HostAddress}}/api/events/receive
34+
CE-SpecVersion: 1.0
35+
CE-Type: "com.example.myevent"
36+
CE-Source: "urn:example-com:mysource:abc"
37+
CE-Id: "{{$guid}}"
38+
3139
### Send unsupported media type (XML) via Binary mode
3240

3341
POST {{HostAddress}}/api/events/receive

0 commit comments

Comments
 (0)