ditto icon indicating copy to clipboard operation
ditto copied to clipboard

Headers default value and restrictions

Open antoniyatrifonova opened this issue 2 years ago • 3 comments

According the specification:

  1. What is the default value for the following headers?
  • content-type
  • correlation-id
  • ditto-originator
  • if-match
  • if-none-match
  • version
  1. 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 the timeout?

antoniyatrifonova avatar Mar 28 '22 14:03 antoniyatrifonova

Hi @antoniyatrifonova

  1. 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 and if-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
  2. 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 the HeaderValueValidators.getTimeoutValueValidator() which uses DittoDuration.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 the HeaderValueValidators.getNonEmptyValidator() - so no, it may not be empty
    • etc.

thjaeckle avatar Mar 30 '22 14:03 thjaeckle

Hi, @thjaeckle It is possible to provide this information in the documentation here - Doc ? Our implementation is based on this documentation. Thank you!

antoniyatrifonova avatar Mar 31 '22 10:03 antoniyatrifonova

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?

thjaeckle avatar Mar 31 '22 13:03 thjaeckle