Search code examples
urirfccoap

What is link format resources's base uri for CoAP


When I was reading RFC6690 on the rules for determining context URI in link format

I failed to understand what it means by "link format resources's base uri"

2.1. Target and Context URIs

Each link conveys one target URI as a URI-reference inside angle brackets ("<>"). The context URI of a link (also called the base URI in [RFC3986]) is determined by the following rules in this specification:

(a) The context URI is set to the anchor parameter, when specified.

My understanding: simply check for "anchor" attribute

(b) Origin of the target URI, when specified.

My understanding: If target URI is an absolute uri (contains origin) then use its origin (without path and query) as context

(c) Origin of the link format resource's base URI.

My understanding: I'm lost, where should I look for this base uri?

I understand that an origin is defined as a combination of URI scheme, host name, and port number

I also understand Base URI is an absolute URI, where relative URI can resolve against.

But I failed to understand what does "base uri" mean in the context of RFC6690 Section 2.1

If resource target uri is not absolute uri and don't have an origin, then how can I find the origin of link format resource's base uri?


Solution

  • RFC6690 mixes concepts here ("The context URI of a link (also called the base URI[...])" -- context and base URI are distinct concepts). What they mean by base URI here is the URI pointed to by the anchor attribute (which, when missing, defaults to the URI the document was requested from).

    The prevalent interpretation seems to be that the link's context is the anchor attribute resolved against the origin of the requested URI (when no anchor is there, it is the origin of the requested URI), and the link's target is the part between the angular brackets resolved against the origin of the context. This is not exactly what is written there, but at least it works with the examples given in the same document.

    The rules as set out there are so confusing (and, worst of all, different from the very similar ones in the Link header) that even if you follow them to the letter, you can not expect interoperability: Of all the implementations I surveyed for the CoRE mailing list, none considered the anchor properly in the resolution. I suggest you stick with Limited Link Format (defined in the Resource Directory Draft), which is compatible with the resolution steps both of Link headers and RFC6690, and accompanied by a walk-through.

    (I do have high hopes for all link-format to be replaced by CoRAL on the long run, but that has not progressed far enough that I would recommend it for implementation anywhere near a production environment.)