Header value must be of type str or bytes, not <class 'int'>
dietzi opened this issue · 3 comments
I've tested your code with this error by sending audio:
connected:/audio send 49176######## test.mp3
SEND: set
iq
DEBUG:yowsup.layers.logger.layer:tx:
<encr_media type="audio" hash="d+EzRjJNKEJ3SkCf26kq5rtiHurmyFTO7q64yrR40JI=" size="123507">
</encr_media>
SEND: set
iq
DEBUG:yowsup.layers.logger.layer:tx:
<encr_media type="audio" hash="d+EzRjJNKEJ3SkCf26kq5rtiHurmyFTO7q64yrR40JI=" size="123507">
</encr_media>
<encr_media url="https://mmg.whatsapp.net/u/f/GTymZJdNhkSeHrUASXGLQFokMV8ABV9ywmVbhg/AufB8XonzR4Slig5fHfTw6Ba3qe1TJabPCX4sjKzvBNQ">
</encr_media>
RECEIVE: result
iq
FILE TYPE
audio/mpeg
ERROR:yowsup.layers.protocol_media.mediauploader:Error occured at transfer Header value 123932 must be of type str or bytes, not <class 'int'>
Traceback (most recent call last):
File "/usr/local/lib/python3.5/dist-packages/requests/utils.py", line 868, in check_header_validity
if not pat.match(value):
TypeError: expected string or bytes-like objectDuring handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/mdroot/bet/yowsup/yowsup/layers/protocol_media/mediauploader.py", line 155, in run
response = requests.post(uploadUrl, data=data, headers=headers)
File "/usr/local/lib/python3.5/dist-packages/requests/api.py", line 112, in post
return request('post', url, data=data, json=json, **kwargs)
File "/usr/local/lib/python3.5/dist-packages/requests/api.py", line 58, in request
return session.request(method=method, url=url, **kwargs)
File "/usr/local/lib/python3.5/dist-packages/requests/sessions.py", line 488, in request
prep = self.prepare_request(req)
File "/usr/local/lib/python3.5/dist-packages/requests/sessions.py", line 431, in prepare_request
hooks=merge_hooks(request.hooks, self.hooks),
File "/usr/local/lib/python3.5/dist-packages/requests/models.py", line 306, in prepare
self.prepare_headers(headers)
File "/usr/local/lib/python3.5/dist-packages/requests/models.py", line 440, in prepare_headers
check_header_validity(header)
File "/usr/local/lib/python3.5/dist-packages/requests/utils.py", line 872, in check_header_validity
"not %s" % (value, type(value)))
requests.exceptions.InvalidHeader: Header value 123932 must be of type str or bytes, not <class 'int'>
ERROR:yowsup.demos.cli.layer:Upload file test.mp3 to https://mmg.whatsapp.net/u/f/GTymZJdNhkSeHrUASXGLQFokMV8ABV9ywmVbhg/AufB8XonzR4Slig5fHfTw6Ba3qe1TJabPCX4sjKzvBNQ for 49176########@s.whatsapp.net failed!
DEBUG:yowsup.layers.logger.layer:rx:
<encr_media url="https://mmg.whatsapp.net/u/f/GTymZJdNhkSeHrUASXGLQFokMV8ABV9ywmbE_Q/AufB8XonzR4Slig5fHfTw6Ba3qe1TJabPCX4sjKzvBNQ">
</encr_media>
I need help.....
Got it.
contentLength = str(contentLength)
Thank's a lot. Would you mind creating a pull request to fix this issue?