LinkFormat

The CoRE Link Format of RFC 6690, application/link-format (ContentFormat.LINK_FORMAT), as served by /.well-known/core.

Properties

Link copied to clipboard
const val CONTENT_TYPE: String

ct, RFC 7252 §7.2.1.

Link copied to clipboard
const val HREF: String

RFC 6690 §4.1: the query name that matches the link target.

Link copied to clipboard
const val INTERFACE: String

if, RFC 6690 §3.2.

Link copied to clipboard
const val OBSERVABLE: String

obs, RFC 7641 §6.

Link copied to clipboard
const val OSCORE: String

osc, RFC 8613 §9: a hint that the target is reachable with OSCORE only.

Link copied to clipboard

rt, RFC 6690 §3.1.

Link copied to clipboard
const val SIZE: String

sz, RFC 6690 §3.3.

Link copied to clipboard
const val TITLE: String

title, RFC 8288.

Functions

Link copied to clipboard
fun filter(links: List<WebLink>, query: List<String>): List<WebLink>

Applies the query filter of RFC 6690 §4.1: each name=value must match an attribute of the link (href matches the target); a value ending in * matches as a prefix, and the values of relation-type attributes match one by one. Queries without = match links that have the attribute.

Link copied to clipboard
fun parse(text: String): List<WebLink>

Parses a link-format document the application supplies; a document from a peer, such as a /.well-known/core response, goes through parseOrNull. Whitespace between links and parameters is tolerated, as RFC 6690 §2 converts HTTP Link headers by removing it.

Link copied to clipboard

Parses text like parse, or returns null where parse throws: for documents a peer sent, whose malformation is the peer's, not the application's. CoapClient.discover reads /.well-known/core with it.

Link copied to clipboard

Writes links separated by commas. Values consisting only of digits are written as tokens (ct=40, sz=262144), all others as quoted strings (rt="temperature-c"), flags without a value (obs).