Merge "[placement] default to accept of application/json when */*"
This commit is contained in:
commit
9cb1e7eb0c
@ -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)
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user