import upyun
up = upyun.UpYun(bucket=BUCKET, username=USERNAME, password=PASSWORD)
up.put('/upyun-python-sdk/ascii.txt', 'abcdefghijklmnopqrstuvwxyz\n')
会有异常
Traceback (most recent call last):
File "R:\up\venv\lib\site-packages\requests\utils.py", line 752, in check_header_validity
if not pat.match(value):
TypeError: expected string or bytes-like object
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "R:\up\venv\lib\site-packages\upyun\modules\httpipe.py", line 59, in do_http_pipe
timeout=self.timeout, files=files)
File "R:\up\venv\lib\site-packages\requests\sessions.py", line 457, in request
prep = self.prepare_request(req)
File "R:\up\venv\lib\site-packages\requests\sessions.py", line 390, in prepare_request
hooks=merge_hooks(request.hooks, self.hooks),
File "R:\up\venv\lib\site-packages\requests\models.py", line 295, in prepare
self.prepare_headers(headers)
File "R:\up\venv\lib\site-packages\requests\models.py", line 409, in prepare_headers
check_header_validity(header)
File "R:\up\venv\lib\site-packages\requests\utils.py", line 756, in check_header_validity
"not %s" % (value, type(value)))
requests.exceptions.InvalidHeader: Header value 27 must be of type str or bytes, not <class 'int'>
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "upyun_test.py", line 5, in <module>
up.put('/upyun-python-sdk/ascii.txt', 'abcdefghijklmnopqrstuvwxyz\n')
File "R:\up\venv\lib\site-packages\upyun\upyun.py", line 91, in put
headers, handler, params, secret)
File "R:\up\venv\lib\site-packages\upyun\rest.py", line 87, in put
h = self.__do_http_request('PUT', key, value, headers)
File "R:\up\venv\lib\site-packages\upyun\rest.py", line 169, in __do_http_request
value, headers, stream)
File "R:\up\venv\lib\site-packages\upyun\modules\httpipe.py", line 81, in do_http_pipe
raise UpYunClientException(e)
upyun.modules.exception.UpYunClientException: Header value 27 must be of type str or bytes, not <class 'int'>
Windows, python 3.5.2, requests 2.11.0, upyun 2.3.5,像下面这样用upyun python sdk:
会有异常
应该是交给requests的Content-Length是int类型造成的……应该str一下吧