Skip quote '=' for token header
If the token is encoded by base64, it may contain '=' char as well. We should skip quoting it. Change-Id: I1ca63d251fa366f0e8e58128d45b729a2489b65c Partial-Bug: #1783290
This commit is contained in:
parent
2c26f2748f
commit
eba4bb06d9
|
@ -66,7 +66,7 @@ def encode_headers(headers):
|
||||||
for h, v in headers.items():
|
for h, v in headers.items():
|
||||||
if v is not None:
|
if v is not None:
|
||||||
# if the item is token, do not quote '+' as well.
|
# if the item is token, do not quote '+' as well.
|
||||||
safe = '+/' if h in TOKEN_HEADERS else '/'
|
safe = '=+/' if h in TOKEN_HEADERS else '/'
|
||||||
if six.PY2:
|
if six.PY2:
|
||||||
# incoming items may be unicode, so get them into something
|
# incoming items may be unicode, so get them into something
|
||||||
# the py2 version of urllib can handle before percent encoding
|
# the py2 version of urllib can handle before percent encoding
|
||||||
|
|
|
@ -467,11 +467,12 @@ class TestClient(testtools.TestCase):
|
||||||
headers = self.mock.last_request.headers
|
headers = self.mock.last_request.headers
|
||||||
self.assertEqual(refreshed_token, headers['X-Auth-Token'])
|
self.assertEqual(refreshed_token, headers['X-Auth-Token'])
|
||||||
# regression check for bug 1448080
|
# regression check for bug 1448080
|
||||||
unicode_token = u'ni\xf1o+'
|
unicode_token = u'ni\xf1o+=='
|
||||||
http_client.auth_token = unicode_token
|
http_client.auth_token = unicode_token
|
||||||
http_client.get(path)
|
http_client.get(path)
|
||||||
headers = self.mock.last_request.headers
|
headers = self.mock.last_request.headers
|
||||||
# Bug #1766235: According to RFC 8187, headers must be
|
# Bug #1766235: According to RFC 8187, headers must be
|
||||||
# encoded as 7-bit ASCII, so expect to see only displayable
|
# encoded as 7-bit ASCII, so expect to see only displayable
|
||||||
# chars in percent-encoding. The '+' char will be not be changed.
|
# chars in percent-encoding. The '+' and '= 'chars will not
|
||||||
self.assertEqual(b'ni%C3%B1o+', headers['X-Auth-Token'])
|
# be changed.
|
||||||
|
self.assertEqual(b'ni%C3%B1o+==', headers['X-Auth-Token'])
|
||||||
|
|
Loading…
Reference in New Issue