Skip to content

GET request with utf-8 query parameter #204

Open
@cwarny

Description

@cwarny

When using the Client class to build a request (through its request method) from a URL that contains query parameters, it seems like the only way to pass the query parameters to that method is by having them already urlencoded in the url (no params argument in the request method). The problem with that is that, in the constructor of the Request class (invoked by the request method of the Client class), the URL is converted to unicode. But if the URL contains utf8 characters, the Request constructor is converting urlencoded utf8 characters to unicode, assuming they are non-urlencoded string. The fact that the utf8 characters have been urlencoded makes the unicode conversion incorrect. In class Request's to_url method, you end up with incorrect query in the following line:

url = (scheme, netloc, path, params, urllib.urlencode(query, True), fragment)

Our use case is interacting with the Twitter API, using their search endpoint with a query in farsi language. The query gets corrupted because of the above process (I think, please confirm) and the Twitter API request returns incorrect results.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions