commit f269023c49dcf24fd42a4933fc7d31f3aaa2e64d
Author: Chris Dent <email address hidden>
Date: Tue Nov 7 15:25:31 2017 +1100
[placement] set accept to application/json if accept not set
If an incoming request to placement does not set the accept header
force it to 'application/json'. This not only ensures that error
responses are in JSON but also that errors early in the middleware
stack do not cause a key error (see the #1724065 bug).
This fix is done by checking headers early in the middleware stack
using the requestlog middleware as a convenient place to do the
check. This overloads requestlog's purpose, but avoids adding yet
more middleware (doing so has some small impact per request).
Fixing bug 1724065 fixes a 500. Fixing bug 1674694 changes (for some
requests) the content type of the bodies of 400-499 responses. This
creates a bit of quandry for microversion handling. If a microversion
is considered required here then it's not clear the global fix is
worth doing and the 500 fix should be limited the microversion
middleware. The intent all along has been that responses should
strive to align with the API-WG errors guideline [1], which assumes
application/json.
Reviewed: https:/ /review. openstack. org/518223 /git.openstack. org/cgit/ openstack/ nova/commit/ ?id=f269023c49d cf24fd42a4933fc 7d31f3aaa2e64d
Committed: https:/
Submitter: Zuul
Branch: master
commit f269023c49dcf24 fd42a4933fc7d31 f3aaa2e64d
Author: Chris Dent <email address hidden>
Date: Tue Nov 7 15:25:31 2017 +1100
[placement] set accept to application/json if accept not set
If an incoming request to placement does not set the accept header
force it to 'application/json'. This not only ensures that error
responses are in JSON but also that errors early in the middleware
stack do not cause a key error (see the #1724065 bug).
This fix is done by checking headers early in the middleware stack
using the requestlog middleware as a convenient place to do the
check. This overloads requestlog's purpose, but avoids adding yet
more middleware (doing so has some small impact per request).
Fixing bug 1724065 fixes a 500. Fixing bug 1674694 changes (for some /json.
requests) the content type of the bodies of 400-499 responses. This
creates a bit of quandry for microversion handling. If a microversion
is considered required here then it's not clear the global fix is
worth doing and the 500 fix should be limited the microversion
middleware. The intent all along has been that responses should
strive to align with the API-WG errors guideline [1], which assumes
application
[1] http:// specs.openstack .org/openstack/ api-wg/ guidelines/ errors. html
Change-Id: Ice27c7080fc2df 097cb387f7438c0 aaf32b4c63d
Closes-Bug: #1724065
Closes-Bug: #1674694