From 8159e851725a572bcb3151e3ba0a79eda995962a Mon Sep 17 00:00:00 2001 From: Ciaran Gultnieks Date: Tue, 13 Nov 2012 08:59:46 +0000 Subject: [PATCH] Allow an auth object to be passed when connecting This means other authentication methods can be used, e.g. digest or NTLM, by simply constructing one of the relevant auth objects supplied with the Requests library. --- easywebdav/client.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/easywebdav/client.py b/easywebdav/client.py index a221704..9518d5e 100644 --- a/easywebdav/client.py +++ b/easywebdav/client.py @@ -61,14 +61,16 @@ class OperationFailed(WebdavException): super(OperationFailed, self).__init__(msg) class Client(object): - def __init__(self, host, port=0, username=None, password=None, + def __init__(self, host, port=0, auth=None, username=None, password=None, protocol='http'): if not port: port = 443 if protocol == 'https' else 80 self.baseurl = '{0}://{1}:{2}'.format(protocol, host ,port) self.cwd = '/' self.session = requests.session() - if username and password: + if auth: + self.session.auth = auth + elif username and password: self.session.auth = (username, password) def _send(self, method, path, expected_code, **kwargs): url = self._get_url(path)