Friday May 27, 2011

100% XML CardDAV query

The CARDDAV:address-data request XML Element allows a client to specify in which format it wishes the address book resources to be returned via the content-type and version XML parameters (See draft-ietf-vcarddav-carddav-10#section-10.4 ).

This, coupled with the soon to be published xCard format (http://tools.ietf.org/html/draft-ietf-vcarddav-vcardxml), can be used to request a 100% XML CardDAV query response: Instead of making a request using:

 <CARDDAV:address-data/>

the client can use something like:

 <CARDDAV:address-data content-type="application/vcard+xml" version="4.0" />

The complete  Request/Response looks like:

>> Request <<


   REPORT /home/bernard/addressbook/ HTTP/1.1
   Host: addressbook.example.com
   Depth: 1
   Content-Type: text/xml; charset="utf-8"
   Content-Length: xxxx

   <?xml version="1.0" encoding="utf-8" ?>
   <C:addressbook-query xmlns:D="DAV:"
                     xmlns:C="urn:ietf:params:xml:ns:carddav">
     <D:prop>
       <D:getetag/>
       <C:address-data content-type="application/vcard+xml" version="4.0"/>
     </D:prop>
     <C:filter/>
   </C:addressbook-query>

>> Response <<


   HTTP/1.1 207 Multi-Status
   Date: Sat, 11 Nov 2006 09:32:12 GMT
   Content-Type: text/xml; charset="utf-8"
   Content-Length: xxxx

   <?xml version="1.0" encoding="utf-8" ?>
   <D:multistatus xmlns:D="DAV:"
                  xmlns:C="urn:ietf:params:xml:ns:carddav">
     <D:response>
       <D:href>/home/bernard/addressbook/v102.vcf</D:href>
       <D:propstat>
         <D:prop>
           <D:getetag>"23ba4d-ff11fb"</D:getetag>
           <C:address-data content-type="application/vcard+xml" version="4.0">
             <vcards xmlns="urn:ietf:params:xml:ns:vcard-4.0">
               <vcard>
                 <fn><text>J. Doe</text></fn>
                 <uid><uri>xxx:12</uri></uid>
                 <email>
                   <parameters><type><text>work</text></type></parameters>
                   <text>john.doe@example.ca</text>
                 </email>
               </vcard>
             </vcards>
           </C:address-data>
         </D:prop>
         <D:status>HTTP/1.1 200 OK</D:status>
       </D:propstat>
     </D:response>
   </D:multistatus>

Now if you combine the above with the use of the "X-HTTP-Method-Override" HTTP header to wrap the REPORT using HTTP POST, you get an "almost browser friendly" CardDAV query.

About

arnaudq

Search

Archives
« April 2014
SunMonTueWedThuFriSat
  
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
   
       
Today
Bookmarks