Skip to content

python-ecosys/requests can not post Chinese, why not add ; charset=UTF-8 to Content-Type? #859

Closed
@alx696

Description

@alx696

Must call .encode('utf-8') if body text contains Chinese:

import requests, json

json_text = json.dumps({"id":"test", "name":"esp32-中文-1"}).encode('utf-8')
response = requests.post('https://mc-th.alx6963445.workers.dev/device', headers = {'X-Custom-UUID': 'test', 'X-Custom-TOKEN':'test'}, data = json_text)
print(response.status_code, response.text)
response.close()

If not call .encode('utf-8') , workers can not receive full body text. The content will be garbled.

Will the problem be solved after setting ; charset=UTF-8 to Content-Type ? https://github.com/micropython/micropython-lib/blob/master/python-ecosys/requests/requests/__init__.py#L110

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions