mirror of
https://github.com/fluencelabs/dweb-transports
synced 2025-03-15 18:30:49 +00:00
Correctly recognize /arc/archive.org
This commit is contained in:
parent
5930809ad1
commit
289362fcdd
@ -56,7 +56,6 @@ class TransportIPFS extends Transport {
|
|||||||
|
|
||||||
Fields:
|
Fields:
|
||||||
ipfs: object returned when starting IPFS
|
ipfs: object returned when starting IPFS
|
||||||
TODO - this is not complete
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
constructor(options) {
|
constructor(options) {
|
||||||
@ -313,7 +312,7 @@ class TransportIPFS extends Transport {
|
|||||||
if (res.remainderPath.length)
|
if (res.remainderPath.length)
|
||||||
{ // noinspection ExceptionCaughtLocallyJS
|
{ // noinspection ExceptionCaughtLocallyJS
|
||||||
throw new errors.TransportError("Not yet supporting paths in p_rawfetch");
|
throw new errors.TransportError("Not yet supporting paths in p_rawfetch");
|
||||||
} //TODO-PATH
|
}
|
||||||
let buff;
|
let buff;
|
||||||
if (res.value.constructor.name === "DAGNode") { // Kludge to replace above, as its not matching the type against the "require" above.
|
if (res.value.constructor.name === "DAGNode") { // Kludge to replace above, as its not matching the type against the "require" above.
|
||||||
// We retrieved a DAGNode, call files.cat (the node will come from the cache quickly)
|
// We retrieved a DAGNode, call files.cat (the node will come from the cache quickly)
|
||||||
|
@ -259,7 +259,7 @@ class TransportWEBTORRENT extends Transport {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async p_addTorrentFromTorrentFile(torrentFilePath, filesPath) {
|
async p_addTorrentFromTorrentFile(torrentFilePath, filesPath) {
|
||||||
// TODO: doc
|
// TODO-API: doc
|
||||||
try {
|
try {
|
||||||
const opts = { path: filesPath };
|
const opts = { path: filesPath };
|
||||||
const oldTorrent = this.webtorrent.get(torrentFilePath);
|
const oldTorrent = this.webtorrent.get(torrentFilePath);
|
||||||
|
@ -28,7 +28,6 @@ class TransportWOLK extends Transport {
|
|||||||
this.options = options; // Dictionary of options
|
this.options = options; // Dictionary of options
|
||||||
this.wolk = undefined;
|
this.wolk = undefined;
|
||||||
this.name = "WOLK"; // For console log etc
|
this.name = "WOLK"; // For console log etc
|
||||||
//TODO: Change name to WOLK once we understand everything
|
|
||||||
this.supportURLs = ['wolk'];
|
this.supportURLs = ['wolk'];
|
||||||
this.supportFunctions = [ 'fetch', 'connection', 'get', 'set', ]; // 'store' - requires chunkdata; 'createReadStream' not implemented
|
this.supportFunctions = [ 'fetch', 'connection', 'get', 'set', ]; // 'store' - requires chunkdata; 'createReadStream' not implemented
|
||||||
this.status = Transport.STATUS_LOADED;
|
this.status = Transport.STATUS_LOADED;
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
const Url = require('url');
|
const Url = require('url');
|
||||||
const errors = require('./Errors');
|
const errors = require('./Errors');
|
||||||
const utils = require('./utils');
|
const utils = require('./utils');
|
||||||
//process.env.DEBUG = "dweb-transports"; //TODO-DEBUG set at top level
|
|
||||||
const debug = require('debug')('dweb-transports');
|
const debug = require('debug')('dweb-transports');
|
||||||
const httptools = require('./httptools');
|
const httptools = require('./httptools');
|
||||||
const each = require('async/each');
|
const each = require('async/each');
|
||||||
@ -202,7 +201,6 @@ class Transports {
|
|||||||
debug("Fetching %s via %s", url.href, t.name);
|
debug("Fetching %s via %s", url.href, t.name);
|
||||||
let data = await t.p_rawfetch(url, opts); // throws errors if fails or timesout
|
let data = await t.p_rawfetch(url, opts); // throws errors if fails or timesout
|
||||||
debug("Fetching %s via %s succeeded %d bytes", url.href, t.name, data.length);
|
debug("Fetching %s via %s succeeded %d bytes", url.href, t.name, data.length);
|
||||||
//TODO-MULTI-GATEWAY working here - it doesnt quite work yet as the "Add" on browser gets different url than on server
|
|
||||||
if (opts.relay && failedtransports.length) {
|
if (opts.relay && failedtransports.length) {
|
||||||
debug("Fetching attempting relay of %d bytes from %s to %o", data.length, url.href, failedtransports.map(t=>t.name));
|
debug("Fetching attempting relay of %d bytes from %s to %o", data.length, url.href, failedtransports.map(t=>t.name));
|
||||||
this._p_rawstore(failedtransports, data)
|
this._p_rawstore(failedtransports, data)
|
||||||
@ -293,8 +291,6 @@ class Transports {
|
|||||||
returns: undefined
|
returns: undefined
|
||||||
throws: TransportError with message being concatenated messages of transports if NONE of them succeed.
|
throws: TransportError with message being concatenated messages of transports if NONE of them succeed.
|
||||||
*/
|
*/
|
||||||
//TODO-REFACTOR remove dependecy on the object having a .preflight, this should be handled one layer up.
|
|
||||||
//TODO-REFACTOR requires changes in: dweb-transports: TransportXyz, Transport, API.md; dweb-objects: CommonList.js, test.js; dweb-serviceworker/TransportsProxy.js;
|
|
||||||
//TODO-MULTI-GATEWAY might be smarter about not waiting but Promise.race is inappropriate as returns after a failure as well.
|
//TODO-MULTI-GATEWAY might be smarter about not waiting but Promise.race is inappropriate as returns after a failure as well.
|
||||||
urls = await this.p_resolveNames(urls); // If naming is loaded then convert to a name
|
urls = await this.p_resolveNames(urls); // If naming is loaded then convert to a name
|
||||||
let tt = this.validFor(urls, "add"); // Valid connected transports that support "store"
|
let tt = this.validFor(urls, "add"); // Valid connected transports that support "store"
|
||||||
@ -788,6 +784,7 @@ class Transports {
|
|||||||
]
|
]
|
||||||
const arcpatts = [ // No overlap between patts & arcpatts, so order unimportant
|
const arcpatts = [ // No overlap between patts & arcpatts, so order unimportant
|
||||||
/^http[s]?:[/]+[^/]+[/](archive).(org)[/]*(.*)/i, // https://localhost;123/(archive.org)/(internal)
|
/^http[s]?:[/]+[^/]+[/](archive).(org)[/]*(.*)/i, // https://localhost;123/(archive.org)/(internal)
|
||||||
|
/^http[s]?:[/]+[^/]+[/]arc[/](archive).(org)[/]*(.*)/i, // https://localhost;123/arc/(archive.org)/(internal)
|
||||||
/^http[s]?:[/]+dweb.(\w+)[.]([^/]+)[/]*(.*)/i, // https://dweb.(proto).(dom.ain)/(internal) # Before dweb.dom.ain
|
/^http[s]?:[/]+dweb.(\w+)[.]([^/]+)[/]*(.*)/i, // https://dweb.(proto).(dom.ain)/(internal) # Before dweb.dom.ain
|
||||||
// /^http[s]?:[/]+dweb.([^/]+[.][^/]+[/]*.*)/i, // https://dweb.(dom.ain)/internal) or https://dweb.(domain) Handled by coe on recognizing above
|
// /^http[s]?:[/]+dweb.([^/]+[.][^/]+[/]*.*)/i, // https://dweb.(dom.ain)/internal) or https://dweb.(domain) Handled by coe on recognizing above
|
||||||
/^(http[s])?:[/]+([^/]+)[/]+(.*)/i, // https://dom.ain/pa/th
|
/^(http[s])?:[/]+([^/]+)[/]+(.*)/i, // https://dom.ain/pa/th
|
||||||
|
@ -62,7 +62,6 @@ httptools.p_httpfetch = async function(httpurl, init, {wantstream=false, retries
|
|||||||
init: {headers}
|
init: {headers}
|
||||||
resolves to: data as text or json depending on Content-Type header
|
resolves to: data as text or json depending on Content-Type header
|
||||||
throws: TransportError if fails to fetch
|
throws: TransportError if fails to fetch
|
||||||
//TODO explicitly parameterise if want it to loop
|
|
||||||
*/
|
*/
|
||||||
try {
|
try {
|
||||||
// THis was get("range") but that works when init.headers is a Headers, but not when its an object
|
// THis was get("range") but that works when init.headers is a Headers, but not when its an object
|
||||||
|
Loading…
x
Reference in New Issue
Block a user