httpwebrequest - CalDav sync-token expiry -


in previous question, asked syncing data davical server. ended concluding there bug on davical when querying caldav server invalid sync token, server should return error but, instead, returns whole set of events on server.

so started looking alternative caldav server. use sabredav. followed handy tutorial here.

on there says:

caveats

note server free 'forget' sync-tokens have been issued. in case may needed full-sync again.

in case supplied sync-token not recognized server, http error emitted. sabredav emits 403.

that looks promising : need !

so getting sync-token http://sabre.io/ns/sync/15.

i submit report query follows (maybe that's things wrong?!)

string synctoken = "http://sabre.io/ns/sync/15"; string body = " <d:sync-collection xmlns:d=\"dav:\"> " +               "   <d:sync-token>" + synctoken + "</d:sync-token> " +               "   <d:sync-level>1</d:sync-level> " +               "   <d:prop> " +               "     <d:getetag/> " +               "   </d:prop> " +               " </d:sync-collection> "; request = (httpwebrequest)httpwebrequest.create("http://my.sabredav.com/calendars/example/home/"); request.credentials = new networkcredential("my_user", "my_pwd"); request.method = "report"; request.contenttype = "application/xml"; // set body of request... request.contentlength = body.length; using (stream reqstream = request.getrequeststream()) {     // write string destination text file.     byte[] encodedbody = encoding.utf8.getbytes(body);     reqstream.write(encodedbody, 0, encodedbody.length);     reqstream.close(); }  // send method request , response server. response = (httpwebresponse)request.getresponse(); 

so when send request using valid sync-token http://sabre.io/ns/sync/15 got, empty response:

<?xml version="1.0"?>     <d:multistatus xmlns:d="dav:" xmlns:s="http://sabredav.org/ns" xmlns:cal="urn:ietf:params:xml:ns:caldav" xmlns:cs="http://calendarserver.or /ns/">     <d:sync-token>http://sabre.io/ns/sync/15</d:sync-token> </d:multistatus> 

so far good.

if use previous sync-token know valid @ point (http://sabre.io/ns/sync/14 in case - chance previous number...) changes expected:

    <?xml version="1.0"?>     <d:multistatus xmlns:d="dav:" xmlns:s="http://sabredav.org/ns" xmlns:cal="urn:ietf:params:xml:ns:caldav" xmlns:cs="http://calendarserver.org/ns/">      <d:response>       <d:href>/calendarserver.php/calendars/admin/default/23b351ee-7677-46e3-b5c5-5263e8fca351.ics</d:href>       <d:propstat>        <d:prop>         <d:getetag>&quot;8d8d122a66625ca990252fae652cd2e5&quot;</d:getetag>        </d:prop>        <d:status>http/1.1 200 ok</d:status>       </d:propstat>      </d:response>      <d:sync-token>http://sabre.io/ns/sync/15</d:sync-token>     </d:multistatus> 

but issue is, if use random sync token know has never been issued: http://sabre.io/ns/sync/1234312231344324

i same answer when using latest (current) token:

    <?xml version="1.0"?>     <d:multistatus xmlns:d="dav:" xmlns:s="http://sabredav.org/ns" xmlns:cal="urn:ietf:params:xml:ns:caldav" xmlns:cs="http://calendarserver.org/ns/">      <d:sync-token>http://sabre.io/ns/sync/15</d:sync-token>     </d:multistatus> 

sabredav says it's supposed throw error 403, clearly, it's not here... however, if use invalid sync-token format, token1234, indeed error 403...

so question is: how can make sure sync-token still valid ? so, if token valid , nothing returned, know local cache date or, in case sync-token invalid, need full sync!

this indeed bug in sabre/dav. feel free open bug report it's on our radar. it's never been major concern, 'well behaved clients' never supply sync-token never issued us.

the reason it's happening, because digit ever increasing record id in our database. fetch changes simple sql query > done.

if explicitly want test invalid tokens in client, recommend supply sync-token different format (something doesn't start http://sabre.io/ns/sync).


Comments

Popular posts from this blog

powershell Start-Process exit code -1073741502 when used with Credential from a windows service environment -

twig - Using Twigbridge in a Laravel 5.1 Package -

c# - LINQ join Entities from HashSet's, Join vs Dictionary vs HashSet performance -