openmarshal / npm-webdav-client Goto Github PK
View Code? Open in Web Editor NEWWebDAV Client on npm
License: The Unlicense
WebDAV Client on npm
License: The Unlicense
Update to rfc8607 following the webdav specification.
https://www.ietf.org/rfc/rfc8607.html
So what functions does the current webdav-server
support, and which functions does it not support?
I searched webdav on ietf's datatracker and found rfc as follows.
from rfc 2291 to rfc 8607.
https://datatracker.ietf.org/doc/search?name=webdav&sort=&rfcs=on&activedrafts=on&by=group&group=
I found that webdav has updated many new extension methods and headers and others.
However, some webdav servers or client have incomplete support for these functions.
The release date of these rfc is from February 1998 to June 2019.
I want to know whether there is currently a server or client that implements all webdav functions?
Hello,
Using connection.exists(path, callback)
creates an uncaught exception when the request cannot reach the webdav server. My case happens when my nextcloud server is down or shuts down during this request, which makes res
to be null in the following line:
npm-WebDAV-Client/src/index.ts
Line 287 in ba7280b
There should be a sanity test to check if res
is null before accessing the statusCode
.
Your client is the most preferable to me
I understand that it is a suitable environment for testing your webdav server .
And I want to use this client in my project.
I would like to add the most productive readdir() to obtain the content together with the attributes per one HTTP request
like this:
Connection.prototype.readdir = function (path, callback) {
this.request({
url: path,
method: 'PROPFIND',
headers: {
depth: '1'
}
}, function (e, res, body) {
if (e)
return callback(e);
if (res.statusCode >= 400)
return callback(new HTTPError(res));
try {
var r = {};
var xmlEntries = xml_js_builder_1.XML.parse(body)
.find('DAV:multistatus')
.findMany('DAV:response');
for (let elIndex in xmlEntries) {
let el = xmlEntries[elIndex];
let props = el.find('DAV:propstat').find('DAV:prop');
var davEntry = {};
davEntry.creationDate = new Date(props.find('DAV:creationdate').findText());
davEntry.lastModified = new Date(props.find('DAV:getlastmodified').findText());
davEntry.type = props.find('DAV:resourcetype').findIndex('DAV:collection') != -1 ? 'd' : 'f';
davEntry.size = props.findIndex('DAV:getcontentlength') !== -1 ? parseInt(props.find('DAV:getcontentlength').findText()) : 0;
var href = el.find('DAV:href').findText();
if (href.length <= href.indexOf(path) + path.length + 1)
continue;
href = href.lastIndexOf('/') === href.length - 1 ? href.slice(0, -1) : href;
let name = decodeURI(href.substring(href.lastIndexOf('/') + 1));
r[name] = davEntry;
}
callback(null, r);
}
catch (ex) {
callback(ex);
}
});
};
add http2 connection support
If you are using the webdav client with a url such as...
const client = webdav.Connection({ url: 'http://myserver.com/webdav' ");
And you try to perform a move operation like...
client.move('/foobar', '/barfoo')
You receive a 404 error because on the server side:
https://github.com/OpenMarshal/npm-WebDAV-Server/blob/ca245a2208070fde0bfc8f2610bbcd375fad1eb4/src/server/v2/commands/Move.ts#L22
Source path is '/webdav/foobar' while destination is '/barfoo'. The leading path (root) is included in the source because it is relative to the URI ('http://myserver.com/webdav'
) while the destination is not.
I feel like this is a bug in the client and that it is inconsistent in how it handles paths. This situation requires the user to prepend the root path to the destination when using move()
or copy()
. All other operations use relative paths (as it should be).
This could be "fixed" fairly easily in the client...
https://github.com/OpenMarshal/npm-WebDAV-Client/blob/master/src/index.ts#L373
... by prepending this.root
to pathDestination
. Or by passing the destination as a full URI (relative to the connection base URI), in which case it would be parsed server-side and also be handled correctly.
readdir(path : string, callback : (error : Error, files ?: string[]) => void) : void
// vs.
readdir(path : string) : Promise<string[]>
What do you think?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.