[openstack-dev] [nova][cinder][glance] What should be the response for invalid 'Accpet' header?

Chris Dent cdent+os at anticdent.org
Fri Sep 1 16:00:50 UTC 2017

On Thu, 31 Aug 2017, Singh, Niraj wrote:

> As of now, when user passes 'Accept' header in request other than JSON and XML using curl command then it returns 200 OK response with json format data.
> In api-ref guide [1] also it's not clearly mentioned about what response it should return if invalid value for 'Accept' header is specified. IMO instead of 'HTTP 200 OK' it should return 'HTTP 406 Not Acceptable' response.

I posted this on the bug you created (thanks for that) too but will
paste it here too for completeness:

I generally agree that this is bad behavior and it would be nice if
406 were the response.

However, this isn't violating the HTTP 1.1 RFCs.
https://tools.ietf.org/html/rfc7231#section-5.3.2 says:

"If the header field is present in a request and none of the
available representations for the response have a media type that is
listed as acceptable, the origin server can either honor the header
field by sending a 406 (Not Acceptable) response or disregard the
header field by treating the response as if it is not subject to
content negotiation."

As far as I'm aware very very few (if any) openstack services do
content negotiation. They only return JSON. Given that, it is
acceptable (ha!) for the header to be disregarded if that's what
people choose.

Chris Dent                      (⊙_⊙')         https://anticdent.org/
freenode: cdent                                         tw: @anticdent

More information about the OpenStack-dev mailing list