fully resolve well-known URI (#481)

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 is contained in:
Martin Zimmermann 2016-07-26 21:49:17 +02:00 committed by Markus Unterwaditzer
parent 97bfccdb44
commit 48d72aa7a1

View file

@ -127,10 +127,10 @@ class Discover(object):
def find_dav(self):
try:
response = self.session.request(
'GET', self._well_known_uri, allow_redirects=False,
'GET', self._well_known_uri, allow_redirects=True,
headers=self.session.get_default_headers()
)
return response.headers.get('Location', '')
return response.url
except (HTTPError, exceptions.Error):
# The user might not have well-known URLs set up and instead points
# vdirsyncer directly to the DAV server.