From 693d9a65706adec365c1b4be92f022715a18783b Mon Sep 17 00:00:00 2001 From: Samuel Merritt Date: Wed, 23 May 2018 18:15:57 -0700 Subject: [PATCH] Always pass capitalize_response_headers=False to eventlet.wsgi.server() For a while, this was conditional because we supported old Eventlet versions that didn't have this keyword arg. Now, we require new-enough Eventlet that it's always available, so let's get rid of the conditional crud. The flag was introduced in Eventlet 0.15, and we require >= 0.17.4. Change-Id: Id089e29e7ecfc8cec79c520f604aa01bdae0dcf0 --- swift/common/wsgi.py | 10 ++++------ test/unit/common/test_wsgi.py | 11 +++-------- 2 files changed, 7 insertions(+), 14 deletions(-) diff --git a/swift/common/wsgi.py b/swift/common/wsgi.py index 9577230f7a..fcc449d792 100644 --- a/swift/common/wsgi.py +++ b/swift/common/wsgi.py @@ -18,7 +18,6 @@ from __future__ import print_function import errno -import inspect import os import signal import time @@ -543,12 +542,11 @@ def run_server(conf, logger, sock, global_conf=None): server_kwargs = { 'custom_pool': pool, 'protocol': protocol_class, + # Disable capitalizing headers in Eventlet. This is necessary for + # the AWS SDK to work with s3api middleware (it needs an "ETag" + # header; "Etag" just won't do). + 'capitalize_response_headers': False, } - # Disable capitalizing headers in Eventlet if possible. This is - # necessary for the AWS SDK to work with swift3 middleware. - argspec = inspect.getargspec(wsgi.server) - if 'capitalize_response_headers' in argspec.args: - server_kwargs['capitalize_response_headers'] = False try: wsgi.server(sock, app, wsgi_logger, **server_kwargs) except socket.error as err: diff --git a/test/unit/common/test_wsgi.py b/test/unit/common/test_wsgi.py index 5064b5db50..34311e6ea9 100644 --- a/test/unit/common/test_wsgi.py +++ b/test/unit/common/test_wsgi.py @@ -478,8 +478,7 @@ class TestWSGI(unittest.TestCase): with mock.patch('swift.proxy.server.Application.' 'modify_wsgi_pipeline'), \ mock.patch('swift.common.wsgi.wsgi') as _wsgi, \ - mock.patch('swift.common.wsgi.eventlet') as _wsgi_evt, \ - mock.patch('swift.common.wsgi.inspect'): + mock.patch('swift.common.wsgi.eventlet') as _wsgi_evt: conf = wsgi.appconfig(conf_file) logger = logging.getLogger('test') sock = listen_zero() @@ -528,8 +527,7 @@ class TestWSGI(unittest.TestCase): with mock.patch('swift.proxy.server.Application.' 'modify_wsgi_pipeline'), \ mock.patch('swift.common.wsgi.wsgi') as _wsgi, \ - mock.patch('swift.common.wsgi.eventlet') as _eventlet, \ - mock.patch('swift.common.wsgi.inspect'): + mock.patch('swift.common.wsgi.eventlet') as _eventlet: conf = wsgi.appconfig(conf_file, name='proxy-server') logger = logging.getLogger('test') @@ -576,9 +574,7 @@ class TestWSGI(unittest.TestCase): with mock.patch('swift.proxy.server.Application.' 'modify_wsgi_pipeline'), \ mock.patch('swift.common.wsgi.wsgi') as _wsgi, \ - mock.patch('swift.common.wsgi.eventlet'), \ - mock.patch('swift.common.wsgi.inspect', - getargspec=argspec_stub): + mock.patch('swift.common.wsgi.eventlet'): conf = wsgi.appconfig(conf_file) logger = logging.getLogger('test') sock = listen_zero() @@ -618,7 +614,6 @@ class TestWSGI(unittest.TestCase): mock.patch('swift.common.wsgi.wsgi') as _wsgi, \ mock.patch('swift.common.wsgi.eventlet') as _wsgi_evt, \ mock.patch.dict('os.environ', {'TZ': ''}), \ - mock.patch('swift.common.wsgi.inspect'), \ mock.patch('time.tzset'): conf = wsgi.appconfig(conf_dir) logger = logging.getLogger('test')