Skip to content

Commit 1312216

Browse files
author
wallisyan
authored
Merge pull request aliyun#200 from aliyun/fix-nlp-bug
fix nlp bug;
2 parents fe1d64d + e423947 commit 1312216

File tree

3 files changed

+30
-4
lines changed

3 files changed

+30
-4
lines changed

aliyun-python-sdk-core/aliyunsdkcore/client.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -271,9 +271,8 @@ def _implementation_of_do_action(self, request, signer=None):
271271
error_code.SDK_INVALID_REQUEST,
272272
error_msg.get_msg('SDK_INVALID_REQUEST'))
273273

274-
# add core version
275-
core_version = __import__('aliyunsdkcore').__version__
276-
request.add_header('x-sdk-core-version', core_version)
274+
# modify Accept-Encoding
275+
request.add_header('Accept-Encoding', 'identity')
277276

278277
if isinstance(request, CommonRequest):
279278
request.trans_to_acs_request()

aliyun-python-sdk-core/aliyunsdkcore/http/http_request.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ def set_content(self, content, encoding, format=format_type.RAW):
100100
str_md5 = helper.md5_sum(content)
101101
content_length = len(content)
102102
self.__headers[self.content_md5] = str_md5
103-
self.__headers[self.content_length] = content_length
103+
self.__headers[self.content_length] = str(content_length)
104104
self.__headers[self.content_type] = format
105105
self.__encoding = encoding
106106

python-sdk-functional-test/bugs_test.py

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,3 +67,30 @@ def test_bug_with_17602976(self):
6767
assert False
6868
except (ValueError, TypeError, AttributeError) as e:
6969
self.assertEqual("'list' object has no attribute 'get'", e.args[0])
70+
71+
def test_bug_with_nlp(self):
72+
# accept-encoding
73+
from aliyunsdknls_cloud_meta.request.v20180518.CreateTokenRequest import CreateTokenRequest
74+
request = CreateTokenRequest()
75+
request.set_endpoint('nls-meta.cn-shanghai.aliyuncs.com')
76+
response = self.client.do_action_with_exception(request)
77+
response = self.get_dict_response(response)
78+
self.assertTrue(response.get("RequestId"))
79+
80+
def test_bug_with_body_params(self):
81+
# body_params
82+
request = CommonRequest()
83+
request.set_domain("filetrans.cn-shanghai.aliyuncs.com")
84+
request.set_version("2018-08-17")
85+
request.set_product("nls-filetrans")
86+
request.set_action_name("SubmitTask")
87+
request.set_method('POST')
88+
app_key = 'qVwEQ6wIZ9Pxb36t'
89+
file_link = 'https://aliyun-nls.oss-cn-hangzhou.aliyuncs.com/asr/fileASR/' \
90+
'examples/nls-sample-16k.wav'
91+
task = {"app_key": app_key, "file_link": file_link}
92+
task = json.dumps(task)
93+
request.add_body_params("Task", task)
94+
response = self.client.do_action_with_exception(request)
95+
response = self.get_dict_response(response)
96+
self.assertTrue(response.get("RequestId"))

0 commit comments

Comments
 (0)