-
Notifications
You must be signed in to change notification settings - Fork 25
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
[http] Differentiating sse endpoint #342
Comments
I guess more generally we should suggest to always request the content type if more than 1 content type is available for a declared endpoint+verb. We should advise it even more strongly on the subprotocol specifications if they could be multiplexed. |
I think this question:
It deserves its own issue. |
To be noted:
The contentType has to be text/event-stream. So it is implicit in |
This is implemented in WebThings Gateway (Producer) and Krellian Cloud (Consumer). WebThings Gateway always exposes The same approach can be used to differentiate between endpoints for "forms": [
{
"op": ["readallproperties", "writemultipleproperties"],
"href": "properties"
},
{
"op": ["observeallproperties", "unobserveallproperties"],
"href": "properties",
"subprotocol": "sse"
},
{
"op": "queryallactions",
"href": "actions"
},
{
"op": ["subscribeallevents", "unsubscribeallevents"],
"href": "events",
"subprotocol": "sse"
}
] |
See also: w3c/wot-profile#398 |
We are not very clear how one would differentiate different forms when there is the same HTTP endpoint but one form has
readproperty
and the other one hasobserveproperty
. It is not possible to have that in longpolling but it is possible in sse (more on it later). More specifically, we can have the following property:This is technically possible since the Consumer can set the Accept header to
"text/event-stream"
and the Thing can differentiate based on the header and deliver correct value or stream. In this case, we should probably have the second form looking like the following:I think that this header should be a default value when there is
subprotocol:sse
since the EventSource spec says that it is a MAY and not a MUST to send this header (see step 10 at https://html.spec.whatwg.org/multipage/server-sent-events.html#the-eventsource-interface under the green box). Also, it is not clear how this should look like in code. In node-wot, HTTP binding simply uses the event source library at https://github.com/eclipse-thingweb/node-wot/blob/master/packages/binding-http/src/subscription-protocols.ts#L112 . The library however allows headers to be passed at https://github.com/EventSource/eventsource/blob/master/lib/eventsource.js#L35 .Maybe this is an implicit knowledge (also see https://eclipse.dev/ditto/httpapi-sse.html), but I got into the details for the first time. We should at least document this but more behavior description would be nice in this case.
The text was updated successfully, but these errors were encountered: