Search code examples
httpwebdavcaldav

CalDAV client's Report method not requesting for the new event data


I am currently working on development of a caldav synchronization server layer for my calendar application. I am able to answer all the initial requested by the calendar client and currently stuck with the REPORT method.

When PROPFIND is done on Calendar, it asks for CTag and Sync-Token. I do answer this query by providing a CTag and Sync-Token (currently to mock the server, I dynamically generate these value and serve the client).

In the next query, the requested method is REPORT on the calendar as shown below:

Request from client:

REPORT URI  /users/admin%40a.de/calendar/ PROTOCOL HTTP/1.1
----------------------------------------
Accept-encoding  gzip, deflate
Accept  */*
Connection  keep-alive
Prefer  return=minimal
Host  **************
Brief  t
User-agent  Mac+OS+X/10.10.5 (14F27) CalendarAgent/316.1
Depth  1
Authorization  Basic YWRtaW5AYS5kZTpwYXNz
Accept-language  en-us
Content-type  text/xml
Content-length  260
Request body: <?xml version="1.0" encoding="UTF-8"?>
<A:sync-collection xmlns:A="DAV:">
  <A:sync-token>http://calserver.org/ns/sync-token/1</A:sync-token>
  <A:sync-level>1</A:sync-level>
  <A:prop>
    <A:getcontenttype/>
    <A:getetag/>
  </A:prop>
</A:sync-collection>

Response from the Server:

Response header

Content-type: text/calendar;  charset=UTF-8
Connection:   keep-alive
Date  Thu, 17 Dec 2015 19:35:40 GMT
Transfer-encoding  chunked
Http/1.1  207 Multi-Status

Response body

<?xml version=\"1.0\" encoding=\"UTF-8\"?>
<D:multistatus xmlns:D=\"DAV:\" xmlns:C=\"urn:ietf:params:xml:ns:caldav\" xmlns:E=\"urn:ietf:params:xml:ns:carddav\">
<D:response>
 <D:propstat>
  <D:href>/calendar/2601ddd19c1001.ics</D:href>
  <D:prop>
         <D:getcontenttype>text/calendar</D:getcontenttype>
         <D:getetag>"334411222s12"</D:getetag>
  </D:prop>
  <D:status>HTTP/1.1 200 OK</D:status>
 </D:propstat>
</D:response>
</D:multistatus>

Now my question is, In the server-response, I answer the REPORT method that a new event has been created by providing a new ETag value, but the data is not requested by the Client ??

How and when should I serve the calendar data of the new event and what would be the request from client ???


Solution

    • Content-type should not be text/xml, It should be text/calendar.
    • The etag needs to be surrounded by double-quotes.
    • I'm pretty sure it's a bad idea to use a + in the uri the way you did. If you want to encode a space, use %20 instead, but it's probably even better to completely avoid any sort of special encoding.
    • The response to a sync-collection report also must have the current sync-token in the response body. See https://www.rfc-editor.org/rfc/rfc6578#section-6.4