Suppose my HTTP server code implements the GET method on /example, replying with either JSON or HTML depending on the Accept header and setting Vary: Accept. The same data are also available without content negotiation at /example.json and /example.html, respectively.
Would I be using the canonical link relation correctly if I set Link: </example.json>;rel=canonical on /example when serving JSON, but Link: </example.html>;rel=canonical when serving HTML?
(A similar scenario could be constructed for entirely user-facing pages when using Accept-Language to choose the default language, provided that I don’t want to pay the cost of a redirect.)