Merge "Made 507s report drive, if known."
This commit is contained in:
commit
c840bd44a7
@ -21,6 +21,7 @@ environments and response values into objects that are more friendly to
|
||||
interact with.
|
||||
"""
|
||||
|
||||
from collections import defaultdict
|
||||
from cStringIO import StringIO
|
||||
import UserDict
|
||||
import time
|
||||
@ -87,7 +88,7 @@ RESPONSE_REASONS = {
|
||||
504: ('Gateway Timeout', 'A timeout has occurred speaking to a '
|
||||
'backend server.'),
|
||||
507: ('Insufficient Storage', 'There was not enough space to save the '
|
||||
'resource.'),
|
||||
'resource. Drive: %(drive)s'),
|
||||
}
|
||||
|
||||
|
||||
@ -964,6 +965,8 @@ class Response(object):
|
||||
title, exp = RESPONSE_REASONS[self.status_int]
|
||||
if exp:
|
||||
body = '<html><h1>%s</h1><p>%s</p></html>' % (title, exp)
|
||||
if '%(' in body:
|
||||
body = body % defaultdict(lambda: 'unknown', self.__dict__)
|
||||
self.content_length = len(body)
|
||||
return [body]
|
||||
return ['']
|
||||
|
@ -772,6 +772,20 @@ class TestResponse(unittest.TestCase):
|
||||
env['HTTP_HOST'] = 'someother:5678'
|
||||
self.assertEquals(resp.host_url(), 'https://someother:5678')
|
||||
|
||||
def test_507(self):
|
||||
resp = swift.common.swob.HTTPInsufficientStorage()
|
||||
content = ''.join(resp._response_iter(resp.app_iter, resp._body))
|
||||
self.assertEquals(
|
||||
content,
|
||||
'<html><h1>Insufficient Storage</h1><p>There was not enough space '
|
||||
'to save the resource. Drive: unknown</p></html>')
|
||||
resp = swift.common.swob.HTTPInsufficientStorage(drive='sda1')
|
||||
content = ''.join(resp._response_iter(resp.app_iter, resp._body))
|
||||
self.assertEquals(
|
||||
content,
|
||||
'<html><h1>Insufficient Storage</h1><p>There was not enough space '
|
||||
'to save the resource. Drive: sda1</p></html>')
|
||||
|
||||
|
||||
class TestUTC(unittest.TestCase):
|
||||
def test_tzname(self):
|
||||
|
Loading…
x
Reference in New Issue
Block a user