Merge "[placement] default to accept of application/json when */*"

This commit is contained in:
Zuul 2018-06-01 21:45:58 +00:00 committed by Gerrit Code Review
commit 9cb1e7eb0c
2 changed files with 13 additions and 2 deletions

View File

@ -36,9 +36,10 @@ class RequestLog(object):
LOG.debug('Starting request: %s "%s %s"',
environ['REMOTE_ADDR'], environ['REQUEST_METHOD'],
self._get_uri(environ))
# Set the accept header if it is not otherwise set. This
# Set the accept header if it is not otherwise set or is '*/*'. This
# ensures that error responses will be in JSON.
if not environ.get('HTTP_ACCEPT'):
accept = environ.get('HTTP_ACCEPT')
if not accept or accept == '*/*':
environ['HTTP_ACCEPT'] = 'application/json'
if LOG.isEnabledFor(logging.INFO):
return self._log_app(environ, start_response)

View File

@ -184,3 +184,13 @@ tests:
response_forbidden_headers:
- last-modified
- cache-control
- name: test starred accept and errors
GET: /resource_providers/foo
request_headers:
accept: "*/*"
status: 404
response_headers:
content-type: application/json
response_json_paths:
$.errors[0].title: Not Found