-
Notifications
You must be signed in to change notification settings - Fork 1k
urequests: miscalculation of Content-Length when dealling with unicode data #251
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Perhaps, you should call .encode() on your side instead? |
Yup, it's works correctly in micorpython 1.9.3 on nodemcu with eps8266. And ascii data works well too. Before I fix this, There's no problem when dealling with ascii datas. |
If it wasn't clear, you should call .encode() method in your application, and pass (This issue can remain open. If there will be a dozen more similar reports from users, the issue can be reconsidered.) |
This is the part of my app. For exsamples:
I'v tried data = None, headers = None, json = jsonmsg. The resluts are the same as exsamples. |
@7th-heaven I encountered same issue,, this is my solution: It looks like DingTalk's API....I've tested and proven that works |
code in urequests ver 0.5.1:
s.write(b"Content-Length: %d\r\n" % len(data))
"len" calcs a single unicode as 1 length.
to correct it. encode the data before calcs the length
as:
s.write(b"Content-Length: %d\r\n" % len(data.encode('')))
plz fix it.
The text was updated successfully, but these errors were encountered: