Add content-type without spaces

In public cloud implementation, the tomcat module
(specifically tomcat-coyote) used by the api-gateway
will eliminate the space within the content-type,
e.g ret = ret + ";charset=" + this.characterEncoding;

In the current rfc7231 standard, all the following
content-type are permissible and equivalent:
test/html;charset=utf-8
test/html;charset=UTF-8
test/HTML;Charset="utf-8"
test/html; charset="utf-8"
(https://tools.ietf.org/html/rfc7231#section-3.1.1.1)

However in the current tempest rest_client setting,
there is no content-type without space defined in
JSON_ENC and TXT_ENC. This results in defcore test
failure for public cloud since after tomcat module
eliminates the space, the content-type will not be
recognized as a legitimate one.

This patch intends to solve this problem by providing
additional content-type without spaces as allowed in
rfc7231 to JSON_ENC and TXT_ENC so that defcore test
won't be blocked for public cloud implementation.

Change-Id: I718ef0e3ddae513cb911aca38985162027274001
Signed-off-by: zhipengh <huangzhipeng@huawei.com>
This commit is contained in:
zhipengh
2017-02-21 04:40:07 -05:00
parent fc5a3733df
commit d1db0c7363
2 changed files with 20 additions and 2 deletions

View File

@@ -0,0 +1,9 @@
---
upgrade:
- The ``JSON_ENC`` and ``TXT_ENC`` option in the ``_error_checker``
section have been added with additional content-type which are
defined in RFC7231 but missing in the currnt rest_client.py file.
The lack of these additional content-type will cause defcore test
to fail for OpenStack public cloud which uses tomcat module in the
api gateway. The additions are ``application/json;charset=utf-8``,
``text/html;charset=utf-8``,``text/plain;charset=utf-8``

View File

@@ -731,12 +731,21 @@ class RestClient(object):
if resp.status < 400:
return
JSON_ENC = ['application/json', 'application/json; charset=utf-8']
# NOTE(zhipengh): There is a purposefully duplicate of content-type
# with the only difference is with or without spaces, as specified
# in RFC7231.
JSON_ENC = ['application/json', 'application/json; charset=utf-8',
'application/json;charset=utf-8']
# NOTE(mtreinish): This is for compatibility with Glance and swift
# APIs. These are the return content types that Glance api v1
# (and occasionally swift) are using.
# NOTE(zhipengh): There is a purposefully duplicate of content-type
# with the only difference is with or without spaces, as specified
# in RFC7231.
TXT_ENC = ['text/plain', 'text/html', 'text/html; charset=utf-8',
'text/plain; charset=utf-8']
'text/plain; charset=utf-8', 'text/html;charset=utf-8',
'text/plain;charset=utf-8']
if ctype.lower() in JSON_ENC:
parse_resp = True