Only send timeout responses for client timeouts
A timeout could happen in an custom storage backend.
This commit is contained in:
parent
746cd9feb1
commit
df5565f237
@ -460,11 +460,8 @@ class Application:
|
|||||||
return response(*REQUEST_ENTITY_TOO_LARGE)
|
return response(*REQUEST_ENTITY_TOO_LARGE)
|
||||||
|
|
||||||
if is_authenticated:
|
if is_authenticated:
|
||||||
try:
|
status, headers, answer = function(
|
||||||
status, headers, answer = function(
|
environ, base_prefix, path, user)
|
||||||
environ, base_prefix, path, user)
|
|
||||||
except socket.timeout:
|
|
||||||
return response(*REQUEST_TIMEOUT)
|
|
||||||
if (status, headers, answer) == NOT_ALLOWED:
|
if (status, headers, answer) == NOT_ALLOWED:
|
||||||
self.logger.info("Access to %r denied for %s", path,
|
self.logger.info("Access to %r denied for %s", path,
|
||||||
"%r" % user if user else "anonymous user")
|
"%r" % user if user else "anonymous user")
|
||||||
@ -612,6 +609,9 @@ class Application:
|
|||||||
self.logger.warning(
|
self.logger.warning(
|
||||||
"Bad MKCALENDAR request on %r: %s", path, e, exc_info=True)
|
"Bad MKCALENDAR request on %r: %s", path, e, exc_info=True)
|
||||||
return BAD_REQUEST
|
return BAD_REQUEST
|
||||||
|
except socket.timeout as e:
|
||||||
|
self.logger.debug("client timed out", exc_info=True)
|
||||||
|
return REQUEST_TIMEOUT
|
||||||
with self.Collection.acquire_lock("w", user):
|
with self.Collection.acquire_lock("w", user):
|
||||||
item = next(self.Collection.discover(path), None)
|
item = next(self.Collection.discover(path), None)
|
||||||
if item:
|
if item:
|
||||||
@ -638,6 +638,9 @@ class Application:
|
|||||||
self.logger.warning(
|
self.logger.warning(
|
||||||
"Bad MKCOL request on %r: %s", path, e, exc_info=True)
|
"Bad MKCOL request on %r: %s", path, e, exc_info=True)
|
||||||
return BAD_REQUEST
|
return BAD_REQUEST
|
||||||
|
except socket.timeout as e:
|
||||||
|
self.logger.debug("client timed out", exc_info=True)
|
||||||
|
return REQUEST_TIMEOUT
|
||||||
with self.Collection.acquire_lock("w", user):
|
with self.Collection.acquire_lock("w", user):
|
||||||
item = next(self.Collection.discover(path), None)
|
item = next(self.Collection.discover(path), None)
|
||||||
if item:
|
if item:
|
||||||
@ -718,6 +721,9 @@ class Application:
|
|||||||
self.logger.warning(
|
self.logger.warning(
|
||||||
"Bad PROPFIND request on %r: %s", path, e, exc_info=True)
|
"Bad PROPFIND request on %r: %s", path, e, exc_info=True)
|
||||||
return BAD_REQUEST
|
return BAD_REQUEST
|
||||||
|
except socket.timeout as e:
|
||||||
|
self.logger.debug("client timed out", exc_info=True)
|
||||||
|
return REQUEST_TIMEOUT
|
||||||
with self.Collection.acquire_lock("r", user):
|
with self.Collection.acquire_lock("r", user):
|
||||||
items = self.Collection.discover(
|
items = self.Collection.discover(
|
||||||
path, environ.get("HTTP_DEPTH", "0"))
|
path, environ.get("HTTP_DEPTH", "0"))
|
||||||
@ -749,6 +755,9 @@ class Application:
|
|||||||
self.logger.warning(
|
self.logger.warning(
|
||||||
"Bad PROPPATCH request on %r: %s", path, e, exc_info=True)
|
"Bad PROPPATCH request on %r: %s", path, e, exc_info=True)
|
||||||
return BAD_REQUEST
|
return BAD_REQUEST
|
||||||
|
except socket.timeout as e:
|
||||||
|
self.logger.debug("client timed out", exc_info=True)
|
||||||
|
return REQUEST_TIMEOUT
|
||||||
with self.Collection.acquire_lock("w", user):
|
with self.Collection.acquire_lock("w", user):
|
||||||
item = next(self.Collection.discover(path), None)
|
item = next(self.Collection.discover(path), None)
|
||||||
if not isinstance(item, storage.BaseCollection):
|
if not isinstance(item, storage.BaseCollection):
|
||||||
@ -770,6 +779,9 @@ class Application:
|
|||||||
self.logger.warning(
|
self.logger.warning(
|
||||||
"Bad PUT request on %r: %s", path, e, exc_info=True)
|
"Bad PUT request on %r: %s", path, e, exc_info=True)
|
||||||
return BAD_REQUEST
|
return BAD_REQUEST
|
||||||
|
except socket.timeout as e:
|
||||||
|
self.logger.debug("client timed out", exc_info=True)
|
||||||
|
return REQUEST_TIMEOUT
|
||||||
with self.Collection.acquire_lock("w", user):
|
with self.Collection.acquire_lock("w", user):
|
||||||
parent_path = storage.sanitize_path(
|
parent_path = storage.sanitize_path(
|
||||||
"/%s/" % posixpath.dirname(path.strip("/")))
|
"/%s/" % posixpath.dirname(path.strip("/")))
|
||||||
@ -844,6 +856,9 @@ class Application:
|
|||||||
self.logger.warning(
|
self.logger.warning(
|
||||||
"Bad REPORT request on %r: %s", path, e, exc_info=True)
|
"Bad REPORT request on %r: %s", path, e, exc_info=True)
|
||||||
return BAD_REQUEST
|
return BAD_REQUEST
|
||||||
|
except socket.timeout as e:
|
||||||
|
self.logger.debug("client timed out", exc_info=True)
|
||||||
|
return REQUEST_TIMEOUT
|
||||||
with self.Collection.acquire_lock("r", user):
|
with self.Collection.acquire_lock("r", user):
|
||||||
item = next(self.Collection.discover(path), None)
|
item = next(self.Collection.discover(path), None)
|
||||||
if not self._access(user, path, "r", item):
|
if not self._access(user, path, "r", item):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user