jsDAV icon indicating copy to clipboard operation
jsDAV copied to clipboard

ETags

Open FND opened this issue 11 years ago • 6 comments

As far as I can tell, jsDAV does not provide an ETag header in GET responses (tested with the current HEAD). Grepping the source reveals various occurrences of "etag" though, so I'm not sure whether this is an intentional omission.

(For context, Apache's WebDAV implementation does provide ETags and also obeys the If-Match header for PUT requests.)

FND avatar Aug 19 '14 08:08 FND

Yes it does, but the default fs backend doesn't support etags, as they tend to slow down the server somewhat.

You can use the fsext (ext as in extended) backend to get etag and extended resource locking support. See https://github.com/mikedeboer/jsDAV/blob/master/test/test_server.js for an example.

Good luck!

mikedeboer avatar Aug 19 '14 09:08 mikedeboer

Ah, that makes sense - fsext seems to work as expected, thanks!

FND avatar Aug 19 '14 09:08 FND

I'm afraid this doesn't seem to work (anymore?) after all: Using the code below, I can either get ETags (with the tree property) or directory indexes (with the node property), but never both.

It's probably a simple oversight, but I couldn't find any documentation and reading the source code didn't get me anywhere either - so any help would be greatly appreciated.

#!/usr/bin/env node
"use strict";

var jsDAV = require("jsDAV/lib/jsdav");
var Tree = require("jsDAV/lib/DAV/backends/fsext/tree"); // required for ETags
var path = require("path");

var root = path.join(__dirname, "data");

jsDAV.debugMode = true;
jsDAV.createServer({
    //node: root,
    tree: Tree.new(root)
}, 8000);

(I'm using the current HEAD - i.e. 21680d5cc41555341e70ffc6adf916644a119516 - and Node v0.12.2, so I'm missing some plugins as described in https://github.com/mikedeboer/jsDAV/issues/119#issuecomment-94309388 - but AFAICT that doesn't seem to be the reason here.)

FND avatar Apr 21 '15 21:04 FND

I can confirm: setting node breaks ETags.

edrex avatar Feb 01 '16 23:02 edrex

It looks like node just is shorthand to instantiate an fs tree at node, and overwrites any passed tree.

Directory listings/PROPFIND don't work in fsext though.

edrex avatar Feb 02 '16 01:02 edrex

Just for fun I copied the getETag impl from fsext to fs and it seems to work fine (both the ETag header and the getetag PROPFIND property). Probably needs optimization though. fsext seems unfinished, and has some stuff I don't need like storing set properties in a per-directory .jsdav JSON file.

edrex avatar Feb 02 '16 01:02 edrex