Closed bourgeoa closed 3 years ago
What's the problem here? I tried the url at timbl.com
and it seems to work properly for me:
@NoelDeMartin This is the issue for example on : https://bourgeoa.solidcommunity.net:8443/public/test.jsonld (you can try it, it is a public link) Firefox and chrome on windows or linux give the same error. What browser are you using ?
I think there is something to deal with the mimetype of the files. As I remember application/json can be read by solidos application/json+ld can not
@scenaristeur agreed. That is what need to be resolved.
We must found where and why the problem occurs. Some server do not have the problem like https://bourgeois.bourgeoa.ga:8560/public/test.jsonld and apparently @NoelDeMartin do not have the problem with the browser he is using.
Using node-fetch directly like with solid-ide solid-file-client there is no problem to PUT or GET. There is also no problem with the test-suite. Nor with rdflib.js unit tests, but these are unit tests.
I tried different version of rdflib and had no success. @timbl thinks it may relate to missing async/await
Here is what get using Solid-Node-Client on https://bourgeoa.solidcommunity.net:8443/public/test.jsonld :
get JSON-LD file :
status 200
content-type application/ld+json
body {}
If I create my own json-ld file and use Solid-Node-Client to put it with content-type application/ld+json, I can read fine and a get returns the JSON I sent in the put as the body. What is the body of this test file?
I just checked with ide and the contents of the file is a pair of empty curly braces. Maybe try the same thing but with acutal JSON-LD content? I use this to test with :
{
"@context": "https://json-ld.org/contexts/person.jsonld",
"@id": "http://dbpedia.org/resource/John_Lennon",
"name": "John Lennon",
"born": "1940-10-09",
"spouse": "http://dbpedia.org/resource/Cynthia_Lennon"
}
I guess that is not the issue. This script succeeds and returns the expected JSON but in the databrowser it shows fetch error with undefined status
const {SolidNodeClient} = require('solid-node-client');
const client = new SolidNodeClient();
const url="https://jeff-zucker.solidcommunity.net:8443/public/test.jsonld";
const jsonld=`
{
"@context": "https://json-ld.org/contexts/person.jsonld",
"@id": "http://dbpedia.org/resource/John_Lennon",
"name": "John Lennon",
"born": "1940-10-09",
"spouse": "http://dbpedia.org/resource/Cynthia_Lennon"
}
`;
async function run(){
await client.login(credentials);
let r1 = await client.fetch(url,{
method: "PUT",
body: jsonld,
headers: {"content-type":"application/ld+json"}
});
let r2 = await client.fetch(url);
console.log("put JSON-LD file : ", r1.status)
console.log("get JSON-LD file : ",r2.status,r2.headers.get('content-type'));
console.log(await r2.text());
}
const credentials = {
"idp": "https://solidcommunity.net:8443",
"username": "jeff-zucker",
"password": "...",
}
run()
Yes @jeff-zucker the problem only arise in datatBrowser The console log is :
HTTP error: Status undefined (undefined) fetching https://bourgeoa.solidcommunity.net:8443/public/test.jsonld
The error is created in rdflib and while the fetchResponse exists, it seems that all or some keys are undefined..
The problem occurs in fetcher.ts line 1213 where nowOrWhenFetched checks the response from a fetch and looks for response.ok. But jsonld returns an indexedFormula and has no ok property. Removing the ok in that line lets the jsonld be displayed. So either we need to check here if the response is an indexedFormula or else we need jsonldHandler to return a Response object with an ok property.
Note : I believe @NoelDeMartin could read jsonld from timbl.com because it uses an older stack, not because he used a different browser.
https://timbl.com/timbl/Public/Test/Content-Type/application/ld-json/
On a server created in december the problem do not occur https://bourgeoa.bourgeoa.ga:8560/public/test.jsonld