Repository navigation
Conversation
|
|
||
| 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 |
There was a problem hiding this comment.
Erik suggests just having the first sentence and dropping everything else (including the stuff below).
|
@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? |
|
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. |
|
@jskeet if someone produces a CE header that looks like this: 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... |
|
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... |
|
Okay, I've now successfully sent a request - and the value of the |
|
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. |
|
I'd expect encoded double quotes to be passed onto the app, but not grouping ones. Not sure about commas. |
|
Where are we with this discussion. 1/ it would be useful to take a position on permissible vs non-permissible encoding. 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 :) |
|
@jskeet this one has been updated, see what you think |
jskeet
left a comment
There was a problem hiding this comment.
This looks good to me, with the suggested typo/hyphenation changes. I'd also be fine with Erik's suggestion.
| encountered during its processing. For clarity, the standard HTTP header | ||
| processing rules apply: | ||
|
|
||
| - Character ranges sourrounded by non-percent encoded double-quotes MUST |
There was a problem hiding this comment.
| - Character ranges sourrounded by non-percent encoded double-quotes MUST | |
| - Character ranges surrounded by non-percent-encoded double-quotes MUST |
The "sourrounded" bit definitely needs fixing; the additional hyphen is to avoid it sounding like "encoded with something other than a percent".
|
|
||
| - Character ranges sourrounded by non-percent encoded double-quotes MUST | ||
| be excluded from whitespace trimming and commas (`,`), normally | ||
| interpretted as header value separators, are treated as normal characters. |
There was a problem hiding this comment.
| interpretted as header value separators, are treated as normal characters. | |
| interpreted as header value separators, are treated as normal characters. |
| be treated as separators between a list of values. Headers with multiple | ||
| values MUST have the same semantic meaning as multiple instances of that | ||
| header name with those values. | ||
| - Leading and trailing (non-percent encoded) whitespace around individual |
There was a problem hiding this comment.
| - Leading and trailing (non-percent encoded) whitespace around individual | |
| - Leading and trailing (non-percent-encoded) whitespace around individual |
| - Leading and trailing (non-percent encoded) whitespace around individual | ||
| values MUST be removed. All non-leading/trailing whitespace MUST remain | ||
| as-is. | ||
| - Character ranges that are sourrounded by non-percent encoded double-quoted |
There was a problem hiding this comment.
| - Character ranges that are sourrounded by non-percent encoded double-quoted | |
| - Character ranges that are surrounded by non-percent-encoded double-quoted |
Signed-off-by: Doug Davis <duglin@gmail.com>
Signed-off-by: Doug Davis <duglin@gmail.com>
Signed-off-by: Doug Davis <duglin@gmail.com>
|
@jskeet made another round of edits - see what you think |
jskeet
left a comment
There was a problem hiding this comment.
Lots of nits; generally happy
|
|
||
| All other [CloudEvents][ce] attributes, including extensions, MUST be | ||
| individually mapped to and from distinct HTTP message header. | ||
| individually mapped to and from distinct HTTP message header and follow |
There was a problem hiding this comment.
| individually mapped to and from distinct HTTP message header and follow | |
| individually mapped to and from distinct HTTP message headers and follow |
| [HTTP specification](https://www.rfc-editor.org/info/rfc9110), | ||
| [section 5](https://www.rfc-editor.org/info/rfc9110/#section-5.1). |
There was a problem hiding this comment.
| [HTTP specification](https://www.rfc-editor.org/info/rfc9110), | |
| [section 5](https://www.rfc-editor.org/info/rfc9110/#section-5.1). | |
| [HTTP specification section 5](https://www.rfc-editor.org/info/rfc9110/#section-5.1). |
(I don't think we need two links to the same document. If anyone wants to see it from the start, they can easily scroll up...)
| CloudEvents implementations MUST use | ||
| [percent-encoding](https://www.rfc-editor.org/info/rfc8187). | ||
|
|
||
| Implementations MAY also choose to encode printable US-ASCII characters. |
There was a problem hiding this comment.
| Implementations MAY also choose to encode printable US-ASCII characters. | |
| Implementations MAY choose to percent-encode printable US-ASCII characters in | |
| addition to the characters required to be encoded by RFC 8187. |
(To make it clear what encoding is used. We can tweak that further though.)
|
|
||
| Implementations MAY also choose to encode printable US-ASCII characters. | ||
|
|
||
| CloudEvents HTTP headers SHOULD NOT leverage the "combined field value" |
There was a problem hiding this comment.
On the grounds that any CloudEvents attribute must be single-valued anyway?
There was a problem hiding this comment.
yup - added back in the text that was dropped to explain why...
| case. Instead, per the HTTP specification, only leading or trailing spaces that | ||
| are not meant to be "stripped" MUST be encoded. Note that all spaces that are | ||
| within double-quoted range of characters, or are non-leading/trailing, | ||
| MUST NOT be stripped. |
There was a problem hiding this comment.
| MUST NOT be stripped. | |
| MUST NOT be stripped by receivers. |
(Just because most of the rest of this is about clients sending requests. Feel free to change receivers to servers.)
| within double-quoted range of characters, or are non-leading/trailing, | ||
| MUST NOT be stripped. | ||
|
|
||
| Processing of double-quotes, MUST adhere to the HTTP specification. |
There was a problem hiding this comment.
| Processing of double-quotes, MUST adhere to the HTTP specification. | |
| Processing of double-quotes MUST adhere to the HTTP specification. |
| Processing of double-quotes, MUST adhere to the HTTP specification. | ||
|
|
||
| Percent-encoding is performed by considering each non-printable Unicode | ||
| character (ones outside the ASCII range of U+0021-U+007E) within the |
There was a problem hiding this comment.
Should the double quote character always be percent-encoded too?
There was a problem hiding this comment.
And do we have to encode a space, if it's already within a string? So for example does "x y" have to be encoded as "x%20y" or is it okay as-is? As the space isn't leading or trailing, I wouldn't expect it to be trimmed.
There was a problem hiding this comment.
No, double quotes should only be encoded if they are part of the actual value. Otherwise, a double-quote is just for grouping purposes. E.g. if I need leading spaces retained then I can encode them or wrap them in double-quotes.
No, you don't need to encode a space that's in a string - so x y can remain x y and it'll work just fine.
| Decoding of an HTTP header value MUST adhere to the HTTP specification. | ||
| For clarity, that includes: | ||
| - removing any non-encoded leading/trailing whitespaces from each value. | ||
| - processing backslashed (`\`) characters within double-quoted ranges. |
There was a problem hiding this comment.
This isn't mentioned in the encoding part as far as I can see. Should it be?
There was a problem hiding this comment.
no it's part of the http spec. I'm trying hard not to duplicate the entire spec - but if you think I should for this I can.... or I can do the other route and remove this "For clarity" section entirely.
| - removing any non-encoded leading/trailing whitespaces from each value. | ||
| - processing backslashed (`\`) characters within double-quoted ranges. | ||
| - removing any non-encoded double-quoted characters from each value. | ||
| - decoded any percent-encoded characters. |
There was a problem hiding this comment.
| - decoded any percent-encoded characters. | |
| - decoding any percent-encoded characters. |
| itself. | ||
| and per the | ||
| [HTTP specification](https://www.rfc-editor.org/info/rfc9110/#section-5), any | ||
| non-printable characters from the US-ASCII character set MUST be encoded. |
There was a problem hiding this comment.
Looking at that RFC, section 5 doesn't actually mention percent-encoding explicitly as far as I can see. I've only skimmed admittedly - should we perhaps clarify exactly which bit of section 5 we're talking about, and maybe link to an additional spec, RFC 3986 perhaps?)
There was a problem hiding this comment.
You're correct that it just says that things must be encoded but it leaves it open for people to choose what encoding mechanism they want. So from that perspective, we're talking about ALL of section 5. I added a link to 3986 for %-encoding.
|
thanks for the review @jskeet . I'd be curious to know what impact (if any) this will have on the C# SDK - I'm hoping none since I don't think it changes much (if anything), other than make it clear that not everything under the sun needs to be encoded :-) |
Signed-off-by: Doug Davis <duglin@gmail.com>
|
I don't think it would make any difference to the C# SDK as we rely on the underlying HTTP client to encode and decode the HTTP headers, and there's nothing here that violates the HTTP spec. The one exception to that might be the handling of invalid UTF-8-encoded headers; would need to check that (and can't do so right now). |
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