-
Notifications
You must be signed in to change notification settings - Fork 35
Add support for the alternate
link relation
#133
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
af1c48d
eefa601
be808f6
caecf69
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5809,7 +5809,7 @@ <h3>LoadDocumentCallback</h3> | |
<ol class="changed"> | ||
<li>Create a new {{Promise}} <var>promise</var> and return it. | ||
The following steps are then executed asynchronously.</li> | ||
<li>Set <var>document</var> to the body retrieved from | ||
<li id="LoadDocumentCallback-step-2">Set <var>document</var> to the body retrieved from | ||
the resource identified by <a data-link-for="LoadDocumentCallback">url</a>, | ||
or by otherwise locating a resource associated with <a data-link-for="LoadDocumentCallback">url</a>. | ||
When requesting remote documents the request MUST prefer <a>Content-Type</a> <code>application/ld+json</code> | ||
|
@@ -5824,6 +5824,13 @@ <h3>LoadDocumentCallback</h3> | |
<li>Set <var>documentUrl</var> to the location of the retrieved resource | ||
considering redirections (exclusive of HTTP status <code>303</code> "See Other" redirects | ||
as discussed in [[?cooluris]]).</li> | ||
<li>If the retrieved resource's <a>Content-Type</a> is not <code>application/ld+json</code> | ||
nor any media type with a <code>+json</code> suffix as defined in [[RFC6839]], | ||
and the response has an HTTP Link Header [[RFC8259]] using the <code>alternate</code> link relation | ||
with type `application/ld+json`, | ||
set <var>url</var> to the associated <code>href</code> relative to the previous <var>url</var> | ||
and restart the algorithm from <a href="#LoadDocumentCallback-step-2">step 2</a>, | ||
ensuring that <var>documentUrl</var> is set to the original <var>url</var>.</li> | ||
<li>If the retrieved resource's <a>Content-Type</a> is <code>application/json</code> | ||
or any media type with a <code>+json</code> suffix as defined in [[RFC6839]] | ||
except <code>application/ld+json</code>, | ||
|
@@ -6372,6 +6379,9 @@ <h2>Changes since JSON-LD Community Group Final Report</h2> | |
a context. When this is set, vocabulary-relative IRIs, such as the | ||
<a>entries</a> of <a>node objects</a>, are expanded or compacted relative | ||
to the <a>base IRI</a> and the <a>vocabulary mapping</a> using string concatenation.</li> | ||
<li>In the <a>LoadDocumentCallback</a>, if the retrieved content is not `application/ld+json` | ||
and there is a link header with `rel=alternate` and `type=application/ld+json`, redirect | ||
to that content.</li> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This probably needs to be discussed (it is not just editorial). This would create a different behaviour when the document is accessed directly, than when it is accessed through the "link header indirection". So I am not a big fan of the idea. I would rather encourage the author of the JSON-LD document to explicitly set the base to the URL o the non-JSON-LD document, if that is the behaviour they intend. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The PR is definitely prospective, as the issue is still marked to be discussed, but I wanted to get it out there and see the consequences. The link header shouldn’t affect any json format, but would affect html content. What document base should be applied can be debated, but using the original document has precedent. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hmm, I think I disagree with @pchampin ... and that we want to treat this like we do with redirects, which I believe uses the original document. The argument for doing what @pchampin suggests would be that there's no way to know ahead of time what the final document will be, so you couldn't set the base to it, whereas you could set the base to the original document if you wanted it to stick. But, processors could have a flag to switch to this other behavior. It seems to me that the sensible default would be the original document. Especially given the way that we expect this feature to be used ... which is that the linked document is really a hidden implementation detail. If you wanted to use the linked document directly you would have specified it instead of some, e.g., HTML document. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 👎 to introducing another flag, though. If the document should have some specific base different from the originally referenced resource, it can use My thought in using the original resource base, rather than the referenced document, is essentially the same reasoning that lead to the semantics of HTTP status 303 for range-14 considerations. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If this use of Once the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What I mentioned on the call Friday was that the only definition of The summary definition is "Gives alternate representations of the current document." but the follow-on expansion on it includes "The meaning of this keyword depends on the values of the other attributes." The examples in that section include alternate CSS styles (i.e. So, using There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Additionally, if we stick with We could use the existing context profile URL (which is used as a There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There's a discussion in Cool URIs:
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, but they do not say that a relative URI could or should be used for that... There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. At this point, I think you need to raise a new issue for discussion, because we seem to have quite different views on this, and discussing in a merged PR isn't a good way to be sure we resolve it. |
||
</ul> | ||
</section> | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"@context": { | ||
"@vocab": "http://example.org/" | ||
}, | ||
"content": "alternate" | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<html> | ||
<head> | ||
<title>Content to be skipped</title> | ||
<script type="application/ld+json"> | ||
{ | ||
"@context": { | ||
"@vocab": "http://example.org/" | ||
}, | ||
"content": "skipped" | ||
} | ||
</script> | ||
</head> | ||
<body> | ||
<p>This content should be skipped</p> | ||
</body> | ||
</html> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
[{ | ||
"http://example.org/content": [{"@value": "alternate"}] | ||
}] |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"@context": { | ||
"@vocab": "http://example.org/" | ||
}, | ||
"content": "alternate" | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"@context": { | ||
"@vocab": "http://example.org/" | ||
}, | ||
"content": "not skipped" | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
[{ | ||
"http://example.org/content": [{"@value": "not skipped"}] | ||
}] |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"@context": { | ||
"@vocab": "http://example.org/" | ||
}, | ||
"content": "alternate" | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"@context": { | ||
"@vocab": "http://example.org/" | ||
}, | ||
"content": "not skipped" | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
[{ | ||
"http://example.org/content": [{"@value": "not skipped"}] | ||
}] |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"@context": { | ||
"@vocab": "http://example.org/" | ||
}, | ||
"content": "alternate" | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"@context": { | ||
"@vocab": "http://example.org/" | ||
}, | ||
"content": "not skipped" | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
[{ | ||
"http://example.org/content": [{"@value": "not skipped"}] | ||
}] |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"@context": { | ||
"@vocab": "http://example.org/" | ||
}, | ||
"@id": "", | ||
"content": "alternate" | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<html> | ||
<head> | ||
<title>Content to be skipped</title> | ||
<script type="application/ld+json"> | ||
{ | ||
"@context": { | ||
"@vocab": "http://example.org/" | ||
}, | ||
"@id": "", | ||
"content": "skipped" | ||
} | ||
</script> | ||
</head> | ||
<body> | ||
<p>This content should be skipped</p> | ||
</body> | ||
</html> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
[{ | ||
"@id": "https://w3c.github.io/json-ld-api/tests/remote-doc/la05-in.html", | ||
"http://example.org/content": [{"@value": "alternate"}] | ||
}] |
Uh oh!
There was an error while loading. Please reload this page.