Merge "Fix error handling in proxy/controllers/base.py."
This commit is contained in:
commit
37b59b0dd3
@ -467,6 +467,8 @@ class Range(object):
|
||||
:param headerval: value of the header as a str
|
||||
"""
|
||||
def __init__(self, headerval):
|
||||
if not headerval:
|
||||
raise ValueError('Invalid Range header: %r' % headerval)
|
||||
headerval = headerval.replace(' ', '')
|
||||
if not headerval.lower().startswith('bytes='):
|
||||
raise ValueError('Invalid Range header: %s' % headerval)
|
||||
|
@ -1061,6 +1061,7 @@ class ResumingGetter(object):
|
||||
self.app.client_timeout)
|
||||
self.app.logger.increment('client_timeouts')
|
||||
except GeneratorExit:
|
||||
exc_type, exc_value, exc_traceback = exc_info()
|
||||
warn = True
|
||||
try:
|
||||
req_range = Range(self.backend_headers['Range'])
|
||||
@ -1068,11 +1069,12 @@ class ResumingGetter(object):
|
||||
req_range = None
|
||||
if req_range and len(req_range.ranges) == 1:
|
||||
begin, end = req_range.ranges[0]
|
||||
if end - begin + 1 == self.bytes_used_from_backend:
|
||||
warn = False
|
||||
if end is not None and begin is not None:
|
||||
if end - begin + 1 == self.bytes_used_from_backend:
|
||||
warn = False
|
||||
if not req.environ.get('swift.non_client_disconnect') and warn:
|
||||
self.app.logger.warning(_('Client disconnected on read'))
|
||||
raise
|
||||
six.reraise(exc_type, exc_value, exc_traceback)
|
||||
except Exception:
|
||||
self.app.logger.exception(_('Trying to send to client'))
|
||||
raise
|
||||
|
@ -249,6 +249,7 @@ class TestRange(unittest.TestCase):
|
||||
6. any combination of the above
|
||||
"""
|
||||
|
||||
_assert_invalid_range(None)
|
||||
_assert_invalid_range('nonbytes=foobar,10-2')
|
||||
_assert_invalid_range('bytes=5-3')
|
||||
_assert_invalid_range('bytes=-')
|
||||
|
Loading…
Reference in New Issue
Block a user