Skip to content

Commit

Permalink
Merge pull request #507 from linkeddata/response.body
Browse files Browse the repository at this point in the history
Do not assume Response.body is set on fetch, use response.text instead
  • Loading branch information
bourgeoa authored Jun 25, 2021
2 parents ce12565 + 57901ed commit 91aa1e2
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
4 changes: 2 additions & 2 deletions src/fetcher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1572,8 +1572,8 @@ export default class Fetcher implements CallbackifyInterface {
if (response.ok) {
if (method === 'PUT' || method === 'PATCH' || method === 'POST' || method === 'DELETE') {
fetcher.invalidateCache (uri)
}
if (response.body) {
} // response.body with Chrome can't be relied on
if (response.text) { // Was: response.body https://github.com/linkeddata/rdflib.js/issues/506
response.text().then(data => {
response.responseText = data
resolve(response)
Expand Down
8 changes: 5 additions & 3 deletions src/update-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ export default class UpdateManager {

/**
* Tests whether a file is editable.
* If the file has a specific annotation that it is machine written,
* If the file has a specific annotation that it is machine written,
* for safety, it is editable (this doesn't actually check for write access)
* If the file has wac-allow and accept patch headers, those are respected.
* and local write access is determined by those headers.
Expand Down Expand Up @@ -165,7 +165,7 @@ export default class UpdateManager {
if ( !this.isHttpUri(uri as string) ) {
if( !wacAllow ) return false;
else return 'LOCALFILE';
}
}

var status = kb.each(response, this.ns.http('status'))
if (status.length) {
Expand Down Expand Up @@ -695,7 +695,9 @@ export default class UpdateManager {
const updates = uniqueDocs.map(doc =>
thisUpdater.update(deletions.filter(st => st.why.equals(doc)),
insertions.filter(st => st.why.equals(doc))))
console.log(` @@@@@@@ updateMany to: ${updates.length} `)
if (updates.length > 1) {
console.log(`@@ updateMany to ${updates.length}: ${uniqueDocs}`)
}
return Promise.all(updates)
}

Expand Down

0 comments on commit 91aa1e2

Please sign in to comment.