]> review.fuel-infra Code Review - openstack-build/cinder-build.git/commitdiff
Fix KeyError while generating a WSGI response
authorhuangtianhua <huangtianhua@huawei.com>
Wed, 11 Dec 2013 09:35:13 +0000 (17:35 +0800)
committerhuangtianhua <huangtianhua@huawei.com>
Wed, 11 Dec 2013 09:35:13 +0000 (17:35 +0800)
The KeyError exception raised while generating a WSGI response based on
the 413 exception. Because there may be no "Retry-After" attribute in the
exception headers.

Change-Id: I89eb1878acc2195775be17fbcba8088f2e00bac1
Closes-Bug: #1259867

cinder/api/openstack/wsgi.py

index 70d127e81361dea34a1aa42f4e1d246763d8e983..f07f75a8e39afee537536734fd088d79280f54a1 100644 (file)
@@ -1169,8 +1169,9 @@ class Fault(webob.exc.HTTPException):
                 'message': gettextutils.get_localized_message(explanation,
                                                               locale)}}
         if code == 413:
-            retry = self.wrapped_exc.headers['Retry-After']
-            fault_data[fault_name]['retryAfter'] = retry
+            retry = self.wrapped_exc.headers.get('Retry-After', None)
+            if retry:
+                fault_data[fault_name]['retryAfter'] = retry
 
         # 'code' is an attribute on the fault tag itself
         metadata = {'attributes': {fault_name: 'code'}}