Fix KeyError while generating a WSGI response

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
This commit is contained in:
huangtianhua 2013-12-11 17:35:13 +08:00
parent 5cb91b70b9
commit 92e058d680
1 changed files with 3 additions and 2 deletions

View 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'}}