fully resolve well-known URI#481
Conversation
Currently, `find_dav` only resolves a single redirect. When using Baïkal behind a proxy with HTTPS, this becomes an issue: 1. dav.example.com/.well-known/caldav (Apache rewrite to http) 2. dav.example.com/dav.php (http) 3. dav.example.com/dav.php (https) The Apache configuration is provided by Baïkal, hence it is also possible to fix it server-side: -RewriteRule /.well-known/carddav /dav.php [R,L] +RewriteRule /.well-known/carddav https://dav.example.com/dav.php [R,L] -RewriteRule /.well-known/caldav /dav.php [R,L] +RewriteRule /.well-known/caldav https://dav.example.com/dav.php [R,L] This commit follows the well-known URI up to 5 times and returns the (hopefully) correctly resolved url.
|
The redirection code is based on DavDroid's (dav4android) implementation: DavResource.java#L114-129. Side note: this is probably a side-effect with requests. The request to the not fully resolved URL (http instead of https) causes Baikal to not return a proper principle url. This issue vanished when I changed the |
|
Rather than just 5, I'd:
That's something like: def find_dav(self):
uri = self._well_known_uri
tried_uris = []
while uri not in tried_uris:
tried_uris.append(uri)
# ... |
|
This redirect logic would already be in requests itself ( On 16 July 2016 22:44:21 CEST, Martin Zimmermann notifications@github.com wrote:
Sent from my Android device with K-9 Mail. Please excuse my brevity. |
|
So you propose to remove the manual redirection handling and use requests' |
|
I was unaware of |
|
Yup On 18 July 2016 16:13:04 CEST, Hugo Osvaldo Barrera notifications@github.com wrote:
Sent from my Android device with K-9 Mail. Please excuse my brevity. |
|
Hey @posativ any update on this? |
Currently, `find_dav` only resolves a single redirect. When using Baïkal behind a proxy with HTTPS, this becomes an issue: 1. dav.example.com/.well-known/caldav (Apache rewrite to http) 2. dav.example.com/dav.php (http) 3. dav.example.com/dav.php (https) The Apache configuration is provided by Baïkal, hence it is also possible to fix it server-side: -RewriteRule /.well-known/carddav /dav.php [R,L] +RewriteRule /.well-known/carddav https://dav.example.com/dav.php [R,L] -RewriteRule /.well-known/caldav /dav.php [R,L] +RewriteRule /.well-known/caldav https://dav.example.com/dav.php [R,L]
|
Yup, I've rebased the new fix. |
|
Crashes because of PyCQA/flake8-import-order#79. The other build issue with Davical is my fault. |
|
Thanks! |
Currently,
find_davonly resolves a single redirect. When using Baïkal behind a proxy with HTTPS, this becomes an issue:The Apache configuration is provided by Baïkal, hence it is also possible to fix it server-side:
-RewriteRule /.well-known/carddav /dav.php [R,L]
+RewriteRule /.well-known/carddav https://dav.example.com/dav.php [R,L]
-RewriteRule /.well-known/caldav /dav.php [R,L]
+RewriteRule /.well-known/caldav https://dav.example.com/dav.php [R,L]
This commit follows the well-known URI up to 5 times and returns the (hopefully) correctly resolved url.