Skip to content

clarity around http headers - #1402

Open
duglin wants to merge 1 commit into
cloudevents:mainfrom
duglin:headers
Open

duglin wants to merge 1 commit into
cloudevents:mainfrom
duglin:headers

Conversation

@duglin

@duglin duglin commented Oct 15, 2026 •

Copy link
Copy Markdown
Collaborator

We don't actually say what should happen if the headers are not percent encoded the way the spec mandates. I'd like to suggest that we still allow the headers if they adhere to normal http processing and there are no other errors in them.

related to: #1397

Signed-off-by: Doug Davis <duglin@gmail.com>

CloudEvent messages that are not encoded per the rules above SHOULD still
try to be accepted rather than generating an error, assuming no other error is
encountered during its processing. For clarity, the standard HTTP header

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Erik suggests just having the first sentence and dropping everything else (including the stuff below).

@duglin

duglin commented Oct 15, 2026

Copy link
Copy Markdown
Collaborator Author

@jskeet given our spec is silent on what to do if people do not %-encode stuff (as a sender), it seems like we need to provide some level of guidance for receivers. Any thoughts?

@jskeet

jskeet commented Oct 15, 2026

Copy link
Copy Markdown
Contributor

Hmm. Personally I've always favoured the approach of "be strict when receiving" as a way of encouraging everyone to do the right thing - I credit that as one reason why there's much less malformed XML in the world than malformed HTML (because XML parsers generally are strict). But I know that's not a popular position.

I think the most practical position is not to particularly require any stance: if you're working in a stack which fails automatically, that's fine, and you don't need to work around it to try to accept non-conformant events. If you're working in a stack which is more lax, then that's fine too. Basically I don't want to put too much work onto SDK owners, given that SDK owner time is pretty scarce.

@duglin

duglin commented Oct 15, 2026

Copy link
Copy Markdown
Collaborator Author

@jskeet if someone produces a CE header that looks like this:

ce-Foo:    "word1    word2"

The spec, today, provides no guidance on what to do. I think it hurts interop (and the spec) to remain silent and then someone chooses to throw an error on this when it's perfectly valid per the HTTP spec. In this respect, I actually think CE has a bug by not allow a "normal" HTTP header value to be used.

What does the C# SDK do on this header?

@jskeet

jskeet commented Oct 15, 2026

Copy link
Copy Markdown
Contributor

@jskeet if someone produces a CE header that looks like this:

ce-Foo:    "word1    word2"

The spec, today, provides no guidance on what to do. I think it hurts interop (and the spec) to remain silent and then someone chooses to throw an error on this when it's perfectly valid per the HTTP spec. In this respect, I actually think CE has a bug by not allow a "normal" HTTP header value to be used.

What does the C# SDK do on this header?

I couldn't tell you offhand, to be honest - I'd have to test it. I'm happy to do that, but not right now...

@jskeet

jskeet commented Oct 17, 2026

Copy link
Copy Markdown
Contributor

Hmm... this is going to be slightly harder to test than I'd expected, because most tools are going to format the headers themselves. We already have an ASP.NET Core sample project to handle the .NET side of things. I might need to resort to netcat...

@jskeet

jskeet commented Oct 17, 2026

Copy link
Copy Markdown
Contributor

Okay, I've now successfully sent a request - and the value of the foo attribute is word1 word2.

@duglin

duglin commented Oct 17, 2026

Copy link
Copy Markdown
Collaborator Author

As expected, and as it should. I think there may be value in telling people this is the correct behavior rather than generating an error due to the lack of %-encoding.

I keep forgetting to mention that I think the spec is ambiguous wrt double-quotes. If they're encoded, are they passed on to the app or not? Are they used for grouping wrt commas? I think our attempt to ensure non-ascii chars are supported has resulted in making the simple cases harder/ambiguous.

@jskeet

jskeet commented Oct 17, 2026

Copy link
Copy Markdown
Contributor

I'd expect encoded double quotes to be passed onto the app, but not grouping ones. Not sure about commas.

@shiva

shiva commented Oct 17, 2026 •

Copy link
Copy Markdown

Where are we with this discussion.

1/ it would be useful to take a position on permissible vs non-permissible encoding.
2/ We should get the standard SDKs to conform with the spec. Since I am already looking at the javascript one, we can take this up next, once I get through the backlog of existing PRs.

P.S: I am in favour of allowing % encoding of space, and passing those through, whereas if the SDKs were used, they should encoding per the spec guidance and avoid this style of encoding. Can't prevent folks from using bad habits from the 80s nonetheless :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants