ditto
ditto copied to clipboard
Headers default value and restrictions
According the specification:
- What is the default value for the following headers?
-
content-type
-
correlation-id
-
ditto-originator
-
if-match
-
if-none-match
-
version
- Are there any restrictions for the header values? For example: It is possible to set empty string for the
correlation-id
? What is the range of thetimeout
?
Hi @antoniyatrifonova
- The mentioned headers do not have static default values which could be specified, however:
- if
content-type
is missing from the headers,application/json
will be assumed for commands - for messages,application/octet-stream
will be assumed -
correlation-id
will be generated (in UUID format) if none was provided -
ditto-originator
cannot be set by a device/application at all, but will always be set by the Ditto backend with the "authorization subject that caused an event" -
if-match
andif-none-match
don't have defaults - if they are missing, no conditional request will be performed -
version
- as Ditto only supports version 2 currently, this will be 2 if omitted - I will fix the spec which says that this may be 1 or 2
- if
- Yes, some headers have restrictions - you can find the used validators here (as last argument of the header enum value): https://github.com/eclipse/ditto/blob/master/base/model/src/main/java/org/eclipse/ditto/base/model/headers/DittoHeaderDefinition.java
- e.g.
timeout
header uses theHeaderValueValidators.getTimeoutValueValidator()
which usesDittoDuration.parseDuration()
: https://github.com/eclipse/ditto/blob/e30d9f93e820d6dcab143727590a44bec7f4f7f9/base/model/src/main/java/org/eclipse/ditto/base/model/common/DittoDuration.java#L61-L77 a "range" is however not enforced currently - the
correlation-id
header uses theHeaderValueValidators.getNonEmptyValidator()
- so no, it may not be empty - etc.
- e.g.
Hi, @thjaeckle It is possible to provide this information in the documentation here - Doc ? Our implementation is based on this documentation. Thank you!
I fear that is a bigger topic as not even all available headers are currently documented on that page. What kind of information do you need and what do you need that information for?