diff --git a/nova/api/openstack/placement/requestlog.py b/nova/api/openstack/placement/requestlog.py index 8b3639e76754..da7be6a37f4a 100644 --- a/nova/api/openstack/placement/requestlog.py +++ b/nova/api/openstack/placement/requestlog.py @@ -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) diff --git a/nova/tests/functional/api/openstack/placement/gabbits/basic-http.yaml b/nova/tests/functional/api/openstack/placement/gabbits/basic-http.yaml index 162301e90141..28ee38210bac 100644 --- a/nova/tests/functional/api/openstack/placement/gabbits/basic-http.yaml +++ b/nova/tests/functional/api/openstack/placement/gabbits/basic-http.yaml @@ -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