api does not handle explicit accept headers correctly

Bug #1567966 reported by Chris Dent
8
This bug affects 1 person
Affects Status Importance Assigned to Milestone
OpenStack Compute (nova)
Confirmed
Low
Unassigned

Bug Description

If you make a request to the compute api with an explicit type set in the 'Accept' header it will ignore it. Ideally what should happen in this case is that the server should response with a 406 <https://httpstatuses.com/406>.

(Examples run with devstack and nova master as of April 8, 2016)

Here are two example one with an accept, one without:

curl -v -H 'x-auth-token: e893759204ff41d49542b9d87520b03a' http://192.168.33.10:8774/v2.1/servers
* Hostname was NOT found in DNS cache
* Trying 192.168.33.10...
* Connected to 192.168.33.10 (192.168.33.10) port 8774 (#0)
> GET /v2.1/servers HTTP/1.1
> User-Agent: curl/7.35.0
> Host: 192.168.33.10:8774
> Accept: */*
> x-auth-token: e893759204ff41d49542b9d87520b03a
>
< HTTP/1.1 200 OK
< Content-Length: 15
< Content-Type: application/json
< X-Openstack-Nova-Api-Version: 2.1
< Vary: X-OpenStack-Nova-API-Version
< X-Compute-Request-Id: req-09186938-8745-498a-9485-4773f29e510a
< Date: Fri, 08 Apr 2016 14:27:24 GMT
<
* Connection #0 to host 192.168.33.10 left intact
{"servers": []}

curl -v -H 'x-auth-token: e893759204ff41d49542b9d87520b03a' -H 'accept: text/plain' http://192.168.33.10:8774/v2.1/servers
* Hostname was NOT found in DNS cache
* Trying 192.168.33.10...
* Connected to 192.168.33.10 (192.168.33.10) port 8774 (#0)
> GET /v2.1/servers HTTP/1.1
> User-Agent: curl/7.35.0
> Host: 192.168.33.10:8774
> x-auth-token: e893759204ff41d49542b9d87520b03a
> accept: text/plain
>
< HTTP/1.1 200 OK
< Content-Length: 15
< Content-Type: application/json
< X-Openstack-Nova-Api-Version: 2.1
< Vary: X-OpenStack-Nova-API-Version
< X-Compute-Request-Id: req-6f5d003c-463e-4dae-b682-1091984e63ed
< Date: Fri, 08 Apr 2016 14:28:32 GMT
<
* Connection #0 to host 192.168.33.10 left intact
{"servers": []}

Same response. Here's a gabbi failed test that may be a bit easier to read and demonstrats the expected result

- name: try bad accept
  desc: why u no 406?
  xfail: True
  GET: /servers
  request_headers:
      accept: text/plain
  status: 406

This is related to the older https://bugs.launchpad.net/nova/+bug/724622 but this is a bit more specific.

Now, obviously, this may not really be considered a bug, depending on how correct the api is supposed to be, but felt worth pointing it out.

Tags: api gabbi
Chris Dent (cdent)
tags: added: gabbi
zhaolihui (zhaolh)
Changed in nova:
assignee: nobody → zhaolihui (zhaolh)
assignee: zhaolihui (zhaolh) → nobody
Revision history for this message
Sylvain Bauza (sylvain-bauza) wrote :

Well, I think all the false return status codes should probably being discussed elsewhere, but having those wrong is IMHO still a bug (because we're not compliant with the RFC), so I'm fine keeping those.

Changed in nova:
status: New → Confirmed
importance: Undecided → Low
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.