eclipse-hono / hono

Eclipse Hono™ Project
https://eclipse.dev/hono
Eclipse Public License 2.0
449 stars 137 forks source link

Pass through user defined headers/properties for commands #1629

Open thjaeckle opened 4 years ago

thjaeckle commented 4 years ago

For the HTTP protocol it would be really useful to leverage defined HTTP headers (e.g. for caching like "ETag", "Age", "Expires") for command messages issued via the HTTP long polling response.

This could be achieved by mapping all custom "application properties" of the AMQP 1.0 message as HTTP headers. For other protocols this might be useful as well. Of course for MQTT 3.1.1 this would not be the case, there passing through headers would probably not have an effect.

What do you think about that proposal?

sophokles73 commented 4 years ago

Are we talking about forwarding headers from devices to downstream messages or vice versa or both? Not sure if I understand correctly how you want to employ the Age and Expires headers in this context, though ...

thjaeckle commented 4 years ago

Well, both directions would be great of course. That way one could specify arbitrary headers (if the protocol supports it). The caching headers could be used to indicate for a device connecting via HTTP when to again try to send data - but this was just an example.

The HTTP spec defines a lot of standard headers, just thought that it would be good to be able to leverage the standard.

sophokles73 commented 4 years ago

The caching headers could be used to indicate for a device connecting via HTTP when to again try to send data - but this was just an example.

Sorry, I do not think that I understand. Can you elaborate a little more?

thjaeckle commented 4 years ago

One simple example: using the If-None-Match header A device could send telemetry data via HTTP defining the header If-None-Match: "42". Then the northbound application only needs to "update" the device when the sequenceNumber (or whatever is sent as value of the header) of the managed device is not "42".

HTTP defines tons of headers and behavior to apply, many of them for caching.

sophokles73 commented 4 years ago

Ok, I see what you mean. However, the main purpose of Hono is abstraction of the underlying transport protocol. Thus, FMPOV we need to make sure that we map the HTTP specific headers to generic AMQP application properties which we can also map from/to other transport protocols. Otherwise we would end up with downstream applications depending on a device being connected using a particular transport protocol.