HTTP redirect for PROPFIND causes GET request



  • Hi, I'm trying to use DAVDroid with Darwin Calendarserver 2.4.dfsg-6 (the version provided by Debian 6.0). DAVDroid accepts the URL (http://<server>:<port>/calendars/users/<username> ) but it doesn't show any calendars or address books to sync. There are no address books but there are three calendars.

    I've traced this with tcpdump (tried inserting the HTTP conversation here but didn't get the XML parts through !&/%§$ Markdown - can send them by mail if you like to).

    It looks like Calendarserver responds to the PROPFIND with an HTTP 301 redirect to append a slash to the calendar URL; and DAVDroid then uses the new URL but makes a GET request rather than another PROPFIND request.

    I tried this with DAVDroid 0.3.5-alpha from F-Droid.


  • developer

    I never experimented with redirects yet. Is it a temporary solution for you to use URLs that don't redirect?



  • Thanks for quick reply! Unfortunately the server itself sends some URLs without slash in its responses (eg. in response to "C:calendar-home-set" PROPFIND request), so communication gets borked again.


  • developer

    Info: Since dbc89cb, trailing slashes are always appended to collection URLs.


  • developer

    I have investigated about redirects and found out the following:

    1. HttpClient (as shipped with Android) changes the method to GET for redirects although this is incorrect according to RFC 2616
    2. HttpClient 4.0 (which seems to be the version coming with Android) doesn't implement RedirectStrategy yet (which allows changing/keeping the HTTP method on redirects), but only uses RedirectHandler (which can only change the URL but always uses GET).

    So, the only solution to handle redirections would be to handle them manually. RFC 2616 states that redirections for methods other than GET and POST mustn't be followed automatically, but of course WebDAV wasn't considered in this document. WebDAV RFC 4918 talks about redirection here and there but leaves many room for interpretation.

    So, I have disabled "follow redirects" for now, so that PROPFIND requests shouldn't be changed to GET erroneously. However, this also means that redirects aren't supported at the moment.

    Does that fix your problem, in combination with the previous commit that appends trailing slashes to collection URLs?



  • Sorry for the late reply. I have tried version 0.3.7-alpha from F-droid. It behaves differently, but still no luck. The phone now shows a notification message ("HTTP-Fehler: 301 Moved Permanently" - ie. "HTTP Error:" localized to German). The app then returns to the screen where URL/username/password are entered, rather than showing an empty list of calendars like before.

    Logcat output:

    I/davdroid.QueryServerDialogFragment(27313): onCreateLoader
    I/davdroid.WebDavResource(27313): Using preemptive Basic Authentication
    D/davdroid.HttpPropfind(27313): Prepared PROPFIND request: <propfind xmlns="DAV:">
    D/davdroid.HttpPropfind(27313):    <prop>
    D/davdroid.HttpPropfind(27313):       <current-user-principal/>
    D/davdroid.HttpPropfind(27313):    </prop>
    D/davdroid.HttpPropfind(27313): </propfind>
    W/SingleClientConnManager(27313): Invalid use of SingleClientConnManager: connection still allocated.
    W/SingleClientConnManager(27313): Make sure to release the connection before allocating another one.
    D/davdroid.WebDavCollection(27313): Received multistatus response: <?xml version='1.0' encoding='UTF-8'?><multistatus xmlns='DAV:'>
    D/davdroid.WebDavCollection(27313):   <response>
    D/davdroid.WebDavCollection(27313):     <href>/calendars/users/oliver/birthdays/</href>
    D/davdroid.WebDavCollection(27313):     <propstat>
    D/davdroid.WebDavCollection(27313):       <prop>
    D/davdroid.WebDavCollection(27313):         <current-user-principal>
    D/davdroid.WebDavCollection(27313):           <href>/principals/__uids__/2faeac7a-0279-583d-8282-ce4c6cd37a6e/</href>
    D/davdroid.WebDavCollection(27313):         </current-user-principal>
    D/davdroid.WebDavCollection(27313):       </prop>
    D/davdroid.WebDavCollection(27313):       <status>HTTP/1.1 200 OK</status>
    D/davdroid.WebDavCollection(27313):     </propstat>
    D/davdroid.WebDavCollection(27313):   </response>
    D/davdroid.WebDavCollection(27313): </multistatus>
    I/davdroid.ServerInfoLoader(27313): Found principal path: /principals/__uids__/2faeac7a-0279-583d-8282-ce4c6cd37a6e/
    D/davdroid.HttpPropfind(27313): Prepared PROPFIND request: <propfind xmlns="DAV:">
    D/davdroid.HttpPropfind(27313):    <prop>
    D/davdroid.HttpPropfind(27313):       <CD:addressbook-home-set xmlns:CD="urn:ietf:params:xml:ns:carddav"/>
    D/davdroid.HttpPropfind(27313):       <C:calendar-home-set xmlns:C="urn:ietf:params:xml:ns:caldav"/>
    D/davdroid.HttpPropfind(27313):    </prop>
    D/davdroid.HttpPropfind(27313): </propfind>
    W/SingleClientConnManager(27313): Invalid use of SingleClientConnManager: connection still allocated.
    W/SingleClientConnManager(27313): Make sure to release the connection before allocating another one.
    D/davdroid.WebDavCollection(27313): Received multistatus response: <?xml version='1.0' encoding='UTF-8'?><multistatus xmlns='DAV:'>
    D/davdroid.WebDavCollection(27313):   <response>
    D/davdroid.WebDavCollection(27313):     <href>/principals/__uids__/2faeac7a-0279-583d-8282-ce4c6cd37a6e/</href>
    D/davdroid.WebDavCollection(27313):     <propstat>
    D/davdroid.WebDavCollection(27313):       <prop>
    D/davdroid.WebDavCollection(27313):         <calendar-home-set xmlns='urn:ietf:params:xml:ns:caldav'>
    D/davdroid.WebDavCollection(27313):           <href xmlns='DAV:'>/calendars/__uids__/2faeac7a-0279-583d-8282-ce4c6cd37a6e</href>
    D/davdroid.WebDavCollection(27313):         </calendar-home-set>
    D/davdroid.WebDavCollection(27313):       </prop>
    D/davdroid.WebDavCollection(27313):       <status>HTTP/1.1 200 OK</status>
    D/davdroid.WebDavCollection(27313):     </propstat>
    D/davdroid.WebDavCollection(27313):     <propstat>
    D/davdroid.WebDavCollection(27313):       <prop>
    D/davdroid.WebDavCollection(27313):         <addressbook-home-set xmlns='urn:ietf:params:xml:ns:carddav'/>
    D/davdroid.WebDavCollection(27313):       </prop>
    D/davdroid.WebDavCollection(27313):       <status>HTTP/1.1 404 Not Found</status>
    D/davdroid.WebDavCollection(27313):     </propstat>
    D/davdroid.WebDavCollection(27313):   </response>
    D/davdroid.WebDavCollection(27313): </multistatus>
    I/davdroid.ServerInfoLoader(27313): Found calendar home set: /calendars/__uids__/2faeac7a-0279-583d-8282-ce4c6cd37a6e
    D/dalvikvm(27313): GC_CONCURRENT freed 1931K, 47% free 4464K/8387K, paused 16ms+12ms, total 137ms
    D/davdroid.HttpPropfind(27313): Prepared PROPFIND request: <propfind xmlns="DAV:">
    D/davdroid.HttpPropfind(27313):    <prop>
    D/davdroid.HttpPropfind(27313):       <CD:addressbook-description xmlns:CD="urn:ietf:params:xml:ns:carddav"/>
    D/davdroid.HttpPropfind(27313):       <C:calendar-description xmlns:C="urn:ietf:params:xml:ns:caldav"/>
    D/davdroid.HttpPropfind(27313):       <displayname/>
    D/davdroid.HttpPropfind(27313):       <resourcetype/>
    D/davdroid.HttpPropfind(27313):    </prop>
    D/davdroid.HttpPropfind(27313): </propfind>
    W/SingleClientConnManager(27313): Invalid use of SingleClientConnManager: connection still allocated.
    W/SingleClientConnManager(27313): Make sure to release the connection before allocating another one.
    

    Server log output:

    
    192.168.0.30 - oliver [08/Nov/2013:23:08:31 +0200] "OPTIONS /calendars/users/oliver/birthdays/ HTTP/1.1" 200 0 "-" "DAVdroid/0.3.6-alpha" i=8008 t=83.5 or=1
    192.168.0.30 - oliver [08/Nov/2013:23:08:31 +0200] "PROPFIND /calendars/users/oliver/birthdays/ HTTP/1.1" 207 416 "-" "DAVdroid/0.3.6-alpha" i=8008 t=131.4 or=1 responses=1
    192.168.0.30 - oliver [08/Nov/2013:23:08:32 +0200] "PROPFIND /principals/__uids__/2faeac7a-0279-583d-8282-ce4c6cd37a6e/ HTTP/1.1" 207 660 "-" "DAVdroid/0.3.6-alpha" i=8008 t=57.5 or=1
    192.168.0.30 - oliver [08/Nov/2013:23:08:33 +0200] "PROPFIND /calendars/__uids__/2faeac7a-0279-583d-8282-ce4c6cd37a6e HTTP/1.1" 301 199 "-" "DAVdroid/0.3.6-alpha" i=8008 t=88.0 or=1
    

    So maybe there's some place where the trailing slash is not appended yet?

    I have also tried to build DAVdroid locally but failed so far, so I can't really give you any detailed debug results.

    Btw. the app uses "DAVdroid/0.3.6-alpha" as user agent even though it is displayed as 0.3.7-alpha in Android app management. Is there maybe something wrong with the built apk?


  • developer

    Should be fixed with ab517bd87dbf2939abd86d653b792e6ae1c32c69, please test with master or 0.3.8



  • FYI: with the lastest commit it works fine - thanks a lot! I also got it built locally now (previously I was missing the correct Android SDK version).


Log in to reply
 

Looks like your connection to Bitfire App Forums was lost, please wait while we try to reconnect.