Skip to content
This repository has been archived by the owner on Mar 30, 2022. It is now read-only.

Multi-status responses #13

Open
stevelacey opened this issue Jan 21, 2014 · 0 comments
Open

Multi-status responses #13

stevelacey opened this issue Jan 21, 2014 · 0 comments

Comments

@stevelacey
Copy link
Contributor

@evert I am doing some work with sync-tokens and sync-collections, and working through some issues with multistatus responses.

When I have an XML response like this:

<?xml  version="1.0"  encoding="UTF-8"?>
<d:multistatus  xmlns:cal="urn:ietf:params:xml:ns:caldav"  xmlns:card="urn:ietf:params:xml:ns:carddav"  xmlns:cs="http://calendarserver.org/ns/"  xmlns:d="DAV:"  xmlns:ical="http://apple.com/ns/ical/">
  <d:response>
    <d:href>/carddav/v1/principals/[email protected]/lists/default/2fd4e578c089c2c</d:href>
    <d:propstat>
      <d:status>HTTP/1.1  200  OK</d:status>
      <d:prop>
        <d:getetag>"2014-01-21T01:52:33.782-08:00"</d:getetag>
      </d:prop>
    </d:propstat>
  </d:response>
  <d:response>
    <d:href>/carddav/v1/principals/[email protected]/lists/default/40318581094cc5a8</d:href>
    <d:status>HTTP/1.1  404  Not  Found</d:status>
  </d:response>
  <d:sync-token>https://www.googleapis.com/carddav/v1/synctoken/0801100118F9F9F2A3828FBC02</d:sync-token>
</d:multistatus>

The parseMultiStatus method of the existing client is giving me a response like:

array (size=2)
  '/carddav/v1/principals/[email protected]/lists/default/2fd4e578c089c2c' => 
    array (size=1)
      200 => 
        array (size=1)
          '{DAV:}getetag' => string '"2014-01-21T01:52:33.782-08:00"' (length=31)
  '/carddav/v1/principals/[email protected]/lists/default/40318581094cc5a8' => 
    array (size=0)
      empty

Should it not have at the very least:

  '/carddav/v1/principals/[email protected]/lists/default/40318581094cc5a8' =>
      404 => array(size=0)

I am guessing it's not doing this because it isn't pulled out by the propertylist since the response for this property does not include a propstat tag.


Additionally, is this the most logical way to work with these responses? Having statuses as child of the href I assume makes sense when the href represents the address book, but when working directly with contacts as in sync, each href will only have 1 status, which makes these return values look a little odd. I can work on improving this (or working with it as is) if you think it's the most sensical way of working with these responses, but otherwise I'll implement something new if you think this could be improved.

Note: the multistatus response also includes a sync token which is ignored by this method, I am thinking of adding a parseSyncToken or parseSyncMultiStatus method that will pull all of this out. An example of what I have working so far returns something like this:

array (size=2)
  'sync-token' => string 'https://www.googleapis.com/carddav/v1/synctoken/0801100118F9F9F2A3828FBC02' (length=74)
  'responses' => 
    array (size=2)
      200 => 
        array (size=2)
          'href' => string '/carddav/v1/principals/[email protected]/lists/default/2fd4e578c089c2c' (length=74)
          'etag' => string '"2014-01-21T01:52:33.782-08:00"' (length=31)
      404 => 
        array (size=1)
          'href' => string '/carddav/v1/principals/[email protected]/lists/default/40318581094cc5a8' (length=75)

but I am still undecided whether this is the way to go, whether the array should be inverted like this, whether to use clark notation for the href / etag, and whether the href should simply be the key (although this makes processing adds/deletes separately a little more faff.

Thoughts appreciated.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant