mikedeboer / jsDAV

jsDAV allows you to easily add WebDAV support to a NodeJS application. jsDAV is meant to cover the entire standard, and attempts to allow integration using an easy to understand API.
http://www.mikedeboer.nl
MIT License
681 stars 159 forks source link

CalDAV: beforeCreateFile #130

Closed MisterFreeze closed 9 years ago

MisterFreeze commented 9 years ago

Hello everyone!

I built a CalDAV server by implementing the caldav iBackend interface and initializing your calendarRoot with it. Most HTTP requests work very nicely with my Thunderbird Lightning plugin. However, creation of CalDAV calendar objects (HTTP-PUT request) fails.

From what I understand, this is caused by the caldav plugin "beforeCreateFile"-event handler expecting dataOrStream not to be null. It fails on validateICal if it is null, which is always the case, as httpPut calls createFile with dataOrStream = null.

One solution that I could see is the modification of DAV.handler#createFile in a way that it fetches the body prior to emitting the "beforeCreateFile" event. (For parent nodes that are not capable of handling streams).

Another solution could be to fetch the iCal content from the request body in the caldav plugin's beforeCreateFile method, just as the beforeWriteContent event handler does.

I tried the last solution and that worked for me.

MisterFreeze commented 9 years ago

fixed by merge