Use HTTP code 307 for redirects

Changed HTTP redirect code from 302 to 307 to ensure the
original HTTP method is left intact. Otherwise some clients
may change PUT/POST to GET on redirect and effectively fail
to perform the change they intended.

Change-Id: I32613e1ebb4a2eaba33c5884ddbd3ec7cf77d6fd
Story: 2005370
Task: 30346
This commit is contained in:
Ilya Etingof 2019-04-04 18:19:56 +02:00
parent caa0593a9c
commit adc16921b4
2 changed files with 8 additions and 1 deletions

View File

@ -0,0 +1,7 @@
---
fixes:
- |
Changed HTTP redirect code from 302 to 307 to ensure the
original HTTP method is left intact. Otherwise some clients
may change PUT/POST to GET on redirect and effectively fail
to perform the change they intended.

View File

@ -126,7 +126,7 @@ def returns_json(decorated_func):
def all_exception_handler(message):
if isinstance(message, error.AliasAccessError):
url = flask.url_for(flask.request.endpoint, identity=message.args[0])
return flask.redirect(url, Response=flask.Response)
return flask.redirect(url, code=307, Response=flask.Response)
return flask.render_template('error.json', message=message), 500