Fix 500 on GET of many-segment manifest.
The proxy_logging middleware was asserting that the response contained either a Content-Length header or a Transfer-Encoding header. If not, it would either add one (if app_iter was a list) or blow up (otherwise). This blowing up is observable on a GET request to a manifest object that references more than swift.common.constraints.CONTAINER_LISTING_LIMIT segments. If a response makes it up to eventlet.wsgi without a Content-Length header, then a "Transfer-Encoding: chunked" header is automatically stuffed into the response by eventlet. Therefore, it's not an error for a response to not have a Content-Length header, and proxy_logging should just let it happen. Fixes bug 1078113. Change-Id: I3751a8ae14dc68bab546f2746b61267a5115e252
This commit is contained in:
parent
217bd202dd
commit
a78b2d5f46
@ -205,10 +205,6 @@ class ProxyLoggingMiddleware(object):
|
||||
elif isinstance(iterable, list):
|
||||
start_response_args[0][1].append(
|
||||
('content-length', str(sum(len(i) for i in iterable))))
|
||||
else:
|
||||
raise Exception('WSGI [proxy-logging]: No content-length '
|
||||
'or transfer-encoding header sent and '
|
||||
'there is content! %r' % chunk)
|
||||
start_response(*start_response_args[0])
|
||||
bytes_sent = 0
|
||||
client_disconnect = False
|
||||
|
@ -391,25 +391,6 @@ class TestProxyLogging(unittest.TestCase):
|
||||
self.assertEquals(resp_body, '')
|
||||
self.assertEquals(log_parts[11], '-')
|
||||
|
||||
def test_no_content_length_no_transfer_encoding_with_str_body(self):
|
||||
app = proxy_logging.ProxyLoggingMiddleware(
|
||||
FakeAppNoContentLengthNoTransferEncoding(
|
||||
body='line1\nline2\n',
|
||||
), {})
|
||||
app.access_logger = FakeLogger()
|
||||
req = Request.blank('/', environ={'REQUEST_METHOD': 'GET'})
|
||||
resp = app(req.environ, start_response)
|
||||
# Python 2.7 can have assertRaises act as a context manager, but python
|
||||
# 2.6 can't. So there's this.
|
||||
try:
|
||||
resp_body = ''.join(resp)
|
||||
except Exception as e:
|
||||
self.assertEquals(
|
||||
"WSGI [proxy-logging]: No content-length or transfer-encoding "
|
||||
"header sent and there is content! 'l'", str(e))
|
||||
else:
|
||||
self.assert_(False)
|
||||
|
||||
def test_req_path_info_popping(self):
|
||||
app = proxy_logging.ProxyLoggingMiddleware(FakeApp(), {})
|
||||
app.access_logger = FakeLogger()
|
||||
|
Loading…
x
Reference in New Issue
Block a user