Fixed problem when connection lost during request executing and nothing was happened, now it raises an exception.
This commit is contained in:
parent
378afe5890
commit
44ec8fcc66
4 changed files with 35 additions and 3 deletions
|
|
@ -68,10 +68,11 @@ def wrap_connection_error(fn):
|
|||
try:
|
||||
res = fn(self, *args, **kw)
|
||||
except requests.ConnectionError:
|
||||
raise NotConnection(self.webdav.hostname)
|
||||
raise NoConnection(self.webdav.hostname)
|
||||
except requests.RequestException as re:
|
||||
raise ConnectionException(re)
|
||||
else:
|
||||
return res
|
||||
|
||||
return _wrapper
|
||||
|
||||
|
||||
|
|
@ -84,6 +85,9 @@ class Client(object):
|
|||
# Max size of file for uploading
|
||||
large_size = 2 * 1024 * 1024 * 1024
|
||||
|
||||
# request timeout in seconds
|
||||
timeout = 30
|
||||
|
||||
# HTTP headers for different actions
|
||||
http_header = {
|
||||
'list': ["Accept: */*", "Depth: 1"],
|
||||
|
|
@ -155,6 +159,7 @@ class Client(object):
|
|||
url=self.get_url(path),
|
||||
auth=(self.webdav.login, self.webdav.password),
|
||||
headers=self.get_headers(action, headers_ext),
|
||||
timeout=self.timeout,
|
||||
data=data
|
||||
)
|
||||
if response.status_code == 507:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue