mirror of
https://github.com/fluencelabs/dweb-transports
synced 2025-03-14 18:10:49 +00:00
Undo createReadStream in browser
This commit is contained in:
parent
99263ec966
commit
c176734266
1
.gitignore
vendored
1
.gitignore
vendored
@ -2,3 +2,4 @@ node_modules
|
|||||||
/package-lock.json
|
/package-lock.json
|
||||||
data.json
|
data.json
|
||||||
/radata/
|
/radata/
|
||||||
|
yarn.lock
|
||||||
|
@ -31,7 +31,11 @@ class TransportHTTP extends Transport {
|
|||||||
this.options = options;
|
this.options = options;
|
||||||
this.urlbase = options.urlbase;
|
this.urlbase = options.urlbase;
|
||||||
this.supportURLs = ['contenthash', 'http','https'];
|
this.supportURLs = ['contenthash', 'http','https'];
|
||||||
this.supportFunctions = ['fetch', 'store', 'add', 'list', 'reverse', 'newlisturls', "get", "set", "keys", "getall", "delete", "newtable", "newdatabase", "createReadStream"]; //Does not support: listmonitor - reverse is disabled somewhere not sure if here or caller
|
this.supportFunctions = ['fetch', 'store', 'add', 'list', 'reverse', 'newlisturls', "get", "set", "keys", "getall", "delete", "newtable", "newdatabase"]; //Does not support: listmonitor - reverse is disabled somewhere not sure if here or caller
|
||||||
|
if (typeof window === "undefined") {
|
||||||
|
// running in node, can support createReadStream, (browser can't - see createReadStream below)
|
||||||
|
this.supportFunctions.push("createReadStream");
|
||||||
|
}
|
||||||
// noinspection JSUnusedGlobalSymbols
|
// noinspection JSUnusedGlobalSymbols
|
||||||
this.supportFeatures = ['fetch.range'];
|
this.supportFeatures = ['fetch.range'];
|
||||||
this.name = "HTTP"; // For console log etc
|
this.name = "HTTP"; // For console log etc
|
||||||
@ -193,7 +197,8 @@ class TransportHTTP extends Transport {
|
|||||||
:param opts: { start: byte to start from; end: optional end byte }
|
:param opts: { start: byte to start from; end: optional end byte }
|
||||||
:returns stream: The readable stream - it is returned immediately, though won't be sending data until the http completes
|
:returns stream: The readable stream - it is returned immediately, though won't be sending data until the http completes
|
||||||
*/
|
*/
|
||||||
|
// This breaks in browsers ... as 's' doesn't have .pipe but has .pipeTo and .pipeThrough neither of which work with stream.PassThrough
|
||||||
|
// TODO See https://github.com/nodejs/readable-stream/issues/406 in case its fixed in which case enable createReadStream in constructor above.
|
||||||
debughttp("createreadstream %s %o", Url.parse(url).href, opts);
|
debughttp("createreadstream %s %o", Url.parse(url).href, opts);
|
||||||
let through;
|
let through;
|
||||||
through = new stream.PassThrough();
|
through = new stream.PassThrough();
|
||||||
|
@ -18,7 +18,7 @@
|
|||||||
"ipfs-http-client": "^29.1.1",
|
"ipfs-http-client": "^29.1.1",
|
||||||
"ipfs-unixfs": "^0.1.16",
|
"ipfs-unixfs": "^0.1.16",
|
||||||
"node-fetch": "^2.3.0",
|
"node-fetch": "^2.3.0",
|
||||||
"readable-stream": "^3.1.1",
|
"readable-stream": "^3.3.0",
|
||||||
"webpack": "^4.29.3",
|
"webpack": "^4.29.3",
|
||||||
"webtorrent": "^0.103.0",
|
"webtorrent": "^0.103.0",
|
||||||
"wolkjs": "git://github.com/wolkdb/wolkjs.git#master",
|
"wolkjs": "git://github.com/wolkdb/wolkjs.git#master",
|
||||||
|
3
test.js
3
test.js
@ -86,7 +86,7 @@ p_test({transport: ["GUN"])
|
|||||||
.then(() => test_transports);
|
.then(() => test_transports);
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
// Intentionally testing this with no connection
|
// Intentionally testing this with no connection
|
||||||
const sampleMagnetURL = "magnet:?xt=urn:btih:465HQWPEN374LABVHUBUPBUX4WZU6HDS&tr=http%3A%2F%2Fbt1.archive.org%3A6969%2Fannounce&tr=http%3A%2F%2Fbt2.archive.org%3A6969%2Fannounce&tr=wss%3A%2F%2Fdweb.archive.org%3A6969&tr=wss%3A%2F%2Ftracker.btorrent.xyz&tr=wss%3A%2F%2Ftracker.openwebtorrent.com&tr=wss%3A%2F%2Ftracker.fastcast.nz&ws=https%3A%2F%2Fdweb.me%2Farc%2Farchive.org%2Fdownload%2F&xs=https%3A%2F%2Fdweb.me%2Farc%2Farchive.org%2Ftorrent%2Ffav-mitra/fav-mitra_members.json";
|
const sampleMagnetURL = "magnet:?xt=urn:btih:465HQWPEN374LABVHUBUPBUX4WZU6HDS&tr=http%3A%2F%2Fbt1.archive.org%3A6969%2Fannounce&tr=http%3A%2F%2Fbt2.archive.org%3A6969%2Fannounce&tr=wss%3A%2F%2Fdweb.archive.org%3A6969&tr=wss%3A%2F%2Ftracker.btorrent.xyz&tr=wss%3A%2F%2Ftracker.openwebtorrent.com&tr=wss%3A%2F%2Ftracker.fastcast.nz&ws=https%3A%2F%2Fdweb.me%2Farc%2Farchive.org%2Fdownload%2F&xs=https%3A%2F%2Fdweb.me%2Farc%2Farchive.org%2Ftorrent%2Ffav-mitra/fav-mitra_members.json";
|
||||||
const sampleMagnetURLMirrorresolve = "http://localhost:4244/magnet/?xt=urn:btih:465HQWPEN374LABVHUBUPBUX4WZU6HDS&tr=http%3A%2F%2Fbt1.archive.org%3A6969%2Fannounce&tr=http%3A%2F%2Fbt2.archive.org%3A6969%2Fannounce&tr=wss%3A%2F%2Fdweb.archive.org%3A6969&tr=wss%3A%2F%2Ftracker.btorrent.xyz&tr=wss%3A%2F%2Ftracker.openwebtorrent.com&tr=wss%3A%2F%2Ftracker.fastcast.nz&ws=https%3A%2F%2Fdweb.me%2Farc%2Farchive.org%2Fdownload%2F&xs=https%3A%2F%2Fdweb.me%2Farc%2Farchive.org%2Ftorrent%2Ffav-mitra/fav-mitra_members.json"
|
const sampleMagnetURLMirrorresolve = "http://localhost:4244/magnet/?xt=urn:btih:465HQWPEN374LABVHUBUPBUX4WZU6HDS&tr=http%3A%2F%2Fbt1.archive.org%3A6969%2Fannounce&tr=http%3A%2F%2Fbt2.archive.org%3A6969%2Fannounce&tr=wss%3A%2F%2Fdweb.archive.org%3A6969&tr=wss%3A%2F%2Ftracker.btorrent.xyz&tr=wss%3A%2F%2Ftracker.openwebtorrent.com&tr=wss%3A%2F%2Ftracker.fastcast.nz&ws=https%3A%2F%2Fdweb.me%2Farc%2Farchive.org%2Fdownload%2F&xs=https%3A%2F%2Fdweb.me%2Farc%2Farchive.org%2Ftorrent%2Ffav-mitra/fav-mitra_members.json"
|
||||||
@ -107,3 +107,4 @@ tests.forEach(t => {
|
|||||||
res = DwebTransports.gatewayUrl(url); console.assert( res === t.gw, "GatewayURL:", url, t.gw,"!==", res);
|
res = DwebTransports.gatewayUrl(url); console.assert( res === t.gw, "GatewayURL:", url, t.gw,"!==", res);
|
||||||
res = DwebTransports.p_resolveNames([url]).then(res => console.assert(res[0] === t.resolveM, "Resolve with Mirror", url, t.resolveM, "!==", res ))
|
res = DwebTransports.p_resolveNames([url]).then(res => console.assert(res[0] === t.resolveM, "Resolve with Mirror", url, t.resolveM, "!==", res ))
|
||||||
})
|
})
|
||||||
|
*/
|
Loading…
x
Reference in New Issue
Block a user