Merge "Drop parameters when connecting to a redirected endpoint"
This commit is contained in:
commit
44e477dfb5
@ -1074,10 +1074,17 @@ class Session(object):
|
||||
logger.warning("Failed to redirect request to %s as new "
|
||||
"location was not provided.", resp.url)
|
||||
else:
|
||||
# NOTE(TheJulia): Location redirects generally should have
|
||||
# URI's to the destination.
|
||||
# https://datatracker.ietf.org/doc/html/rfc7231#section-7.1.2
|
||||
if 'params' in kwargs:
|
||||
kwargs['params'] = {}
|
||||
|
||||
if 'x-openstack-request-id' in resp.headers:
|
||||
kwargs['headers'].setdefault('x-openstack-request-id',
|
||||
resp.headers[
|
||||
'x-openstack-request-id'])
|
||||
|
||||
# NOTE(jamielennox): We don't keep increasing delays.
|
||||
# This request actually worked so we can reset the delay count.
|
||||
connect_retry_delays.reset()
|
||||
|
@ -867,6 +867,17 @@ class RedirectTests(utils.TestCase):
|
||||
self.assertEqual(resp.url, self.REDIRECT_CHAIN[i])
|
||||
self.assertEqual(resp.text, self.DEFAULT_REDIRECT_BODY)
|
||||
|
||||
def test_redirect_with_params(self):
|
||||
params = {'foo': 'bar'}
|
||||
session = client_session.Session(redirect=True)
|
||||
# Note(knikolla): Setting complete_qs to True ensures that the mock
|
||||
# will only match paths including all query strings.
|
||||
self.setup_redirects(final_kwargs={'complete_qs': True})
|
||||
resp = session.get(self.REDIRECT_CHAIN[0], params=params)
|
||||
self.assertResponse(resp)
|
||||
self.assertTrue(len(resp.history), len(self.REDIRECT_CHAIN))
|
||||
self.assertQueryStringIs(None)
|
||||
|
||||
def test_history_matches_requests(self):
|
||||
self.setup_redirects(status_code=301)
|
||||
session = client_session.Session(redirect=True)
|
||||
|
@ -0,0 +1,10 @@
|
||||
---
|
||||
fixes:
|
||||
- |
|
||||
Fixes a condition where URL parameters would be appended to a
|
||||
new URL discovered via a redirect. This was resulting in arguments
|
||||
being duplicated on requests to the new server being redirected to.
|
||||
URL redirects are intended to redirect the requester to the final
|
||||
location, and generally include a fully formatted final destination
|
||||
URL, which would include URL parameters. URL parameters are now dropped
|
||||
when attempting to issue a request once redirected.
|
Loading…
Reference in New Issue
Block a user