Skip to content
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

Encoding is always UTF-8 in POST data #1750

Closed
dmzkrsk opened this issue Mar 25, 2017 · 2 comments · Fixed by #1752
Closed

Encoding is always UTF-8 in POST data #1750

dmzkrsk opened this issue Mar 25, 2017 · 2 comments · Fixed by #1752
Labels

Comments

@dmzkrsk
Copy link

dmzkrsk commented Mar 25, 2017

Long story short

I'm doing a POST request via client.post:

data = aiohttp.FormData({
            'FindText': name,
        }, charset='windows-1251')

client.post(base_url, params={'RowFrom': offset}, data=data)

where name contains some none-latin text ('хан')

Expected behaviour

POST data should contain: FindText=%D5%E0%ED

Actual behaviour

FindText=%D1%85%D0%B0%D0%BD'

Steps to reproduce

Looking through the code of formdata.py:99

urlencode(data, doseq=True).encode(charset),

I noticed, that data is urlencoded in UTF-8 first and then encoded to windows-1251 (and that has no effect on %D1...).

For now, I just manually do in my code:

data = urlencode({
            'FindText': name,
        }, encoding='windows-1251')

And I get the string that I need.

Is it a bug? Or am I doing it wrong?

Your environment

Python 3.6.0 (default, Jan 16 2017, 12:12:55) 
[GCC 6.3.1 20170109] on linux
---
aiohttp==2.0.3
@dmzkrsk dmzkrsk changed the title Encoding in POST data Encoding is always UTF-8 in POST data Mar 25, 2017
alex-eri added a commit to alex-eri/aiohttp that referenced this issue Mar 25, 2017
alex-eri added a commit to alex-eri/aiohttp that referenced this issue Mar 25, 2017
@alex-eri alex-eri mentioned this issue Mar 25, 2017
5 tasks
fafhrd91 added a commit that referenced this issue Mar 26, 2017
Encoding is always UTF-8 in POST data #1750
@fafhrd91
Copy link
Member

fixed in master

@lock
Copy link

lock bot commented Oct 28, 2019

This thread has been automatically locked since there has not been
any recent activity after it was closed. Please open a new issue for
related bugs.

If you feel like there's important points made in this discussion,
please include those exceprts into that new issue.

@lock lock bot added the outdated label Oct 28, 2019
@lock lock bot locked as resolved and limited conversation to collaborators Oct 28, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants