mirror of
https://github.com/samsonjs/vdirsyncer.git
synced 2026-04-27 14:57:41 +00:00
Remove is_subpath checks
This commit is contained in:
parent
943c970286
commit
60c96ae493
1 changed files with 6 additions and 11 deletions
|
|
@ -94,8 +94,7 @@ class Discover(object):
|
||||||
def find_dav(self):
|
def find_dav(self):
|
||||||
try:
|
try:
|
||||||
response = self.session.request('GET', self._well_known_uri,
|
response = self.session.request('GET', self._well_known_uri,
|
||||||
allow_redirects=False,
|
allow_redirects=False)
|
||||||
is_subpath=False)
|
|
||||||
return response.headers.get('Location', '')
|
return response.headers.get('Location', '')
|
||||||
except (HTTPError, exceptions.Error):
|
except (HTTPError, exceptions.Error):
|
||||||
# The user might not have well-known URLs set up and instead points
|
# The user might not have well-known URLs set up and instead points
|
||||||
|
|
@ -116,7 +115,7 @@ class Discover(object):
|
||||||
</d:propfind>
|
</d:propfind>
|
||||||
"""
|
"""
|
||||||
response = self.session.request('PROPFIND', url, headers=headers,
|
response = self.session.request('PROPFIND', url, headers=headers,
|
||||||
data=body, is_subpath=False)
|
data=body)
|
||||||
root = _parse_xml(response.content)
|
root = _parse_xml(response.content)
|
||||||
rv = root.find('.//{DAV:}current-user-principal/{DAV:}href')
|
rv = root.find('.//{DAV:}current-user-principal/{DAV:}href')
|
||||||
if rv is None:
|
if rv is None:
|
||||||
|
|
@ -130,8 +129,7 @@ class Discover(object):
|
||||||
headers['Depth'] = 0
|
headers['Depth'] = 0
|
||||||
response = self.session.request('PROPFIND', url,
|
response = self.session.request('PROPFIND', url,
|
||||||
headers=headers,
|
headers=headers,
|
||||||
data=self._homeset_xml,
|
data=self._homeset_xml)
|
||||||
is_subpath=False)
|
|
||||||
|
|
||||||
root = etree.fromstring(response.content)
|
root = etree.fromstring(response.content)
|
||||||
# Better don't do string formatting here, because of XML namespaces
|
# Better don't do string formatting here, because of XML namespaces
|
||||||
|
|
@ -146,8 +144,7 @@ class Discover(object):
|
||||||
headers = self.session.get_default_headers()
|
headers = self.session.get_default_headers()
|
||||||
headers['Depth'] = 1
|
headers['Depth'] = 1
|
||||||
response = self.session.request('PROPFIND', url, headers=headers,
|
response = self.session.request('PROPFIND', url, headers=headers,
|
||||||
data=self._collection_xml,
|
data=self._collection_xml)
|
||||||
is_subpath=False)
|
|
||||||
root = _parse_xml(response.content)
|
root = _parse_xml(response.content)
|
||||||
done = set()
|
done = set()
|
||||||
for response in root.findall('{DAV:}response'):
|
for response in root.findall('{DAV:}response'):
|
||||||
|
|
@ -224,11 +221,10 @@ class DavSession(object):
|
||||||
self.parsed_url = utils.urlparse.urlparse(self.url)
|
self.parsed_url = utils.urlparse.urlparse(self.url)
|
||||||
self._session = None
|
self._session = None
|
||||||
|
|
||||||
def request(self, method, path, is_subpath=True, **kwargs):
|
def request(self, method, path, **kwargs):
|
||||||
url = self.url
|
url = self.url
|
||||||
if path:
|
if path:
|
||||||
url = utils.urlparse.urljoin(self.url, path)
|
url = utils.urlparse.urljoin(self.url, path)
|
||||||
assert url.startswith(self.url) or not is_subpath
|
|
||||||
if self._session is None:
|
if self._session is None:
|
||||||
self._session = requests_session()
|
self._session = requests_session()
|
||||||
|
|
||||||
|
|
@ -337,8 +333,7 @@ class DavStorage(Storage):
|
||||||
headers = d.session.get_default_headers()
|
headers = d.session.get_default_headers()
|
||||||
|
|
||||||
try:
|
try:
|
||||||
response = d.session.request('MKCOL', collection_url,
|
response = d.session.request('MKCOL', collection_url, data=data,
|
||||||
is_subpath=False, data=data,
|
|
||||||
headers=headers)
|
headers=headers)
|
||||||
except HTTPError as e:
|
except HTTPError as e:
|
||||||
raise NotImplementedError(e)
|
raise NotImplementedError(e)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue