Skip to content

Commit b2b542f

Browse files
committed
Fixed bugs in content and request type for remote context preload.
Added check for acceptable returned content type.
1 parent 762be7e commit b2b542f

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

src/extension.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -565,11 +565,16 @@ async function getJSONwithEmbeddedContext(json_document: vscode.TextDocument) {
565565
console.log("Fetching context from URL " + context[c]);
566566
try {
567567
const response = await axios({
568-
method: 'post',
568+
method: 'get',
569569
url: context[c],
570-
headers: { Accept: "application/ld-json;profile=http://www.w3.org/ns/json-ld#context"}
570+
headers: { Accept: "application/ld+json;profile=http://www.w3.org/ns/json-ld#context"}
571571
})
572-
console.log(response.data);
572+
console.log(response);
573+
574+
if(response.headers['content-type'] != 'application/json' || response.headers['content-type'] != 'text/json' || response.headers['content-type'] != 'application/ld+json') {
575+
throw new Error("Service did not return JSON content type: " + response.headers['content-type']);
576+
}
577+
573578
const remote_context = response.data;
574579
outputChannel.appendLine("Preloaded context from " + context[c]);
575580
expandedContextArray.push(remote_context);

0 commit comments

Comments
 (0)