jamielennox / requests-mock

Mocked responses for the requests library
https://requests-mock.readthedocs.io
Apache License 2.0
440 stars 71 forks source link

qs and query in request_history are converted to lowercase #264

Open ferenc-hechler opened 2 weeks ago

ferenc-hechler commented 2 weeks ago

In a text-callback for GET I used request.qs to get the original parameters as dict. But all keys and values are converted to lowercase.

this bug seems to exist since a long time and it was fixed 2016 in the openstack version.

https://bugs.launchpad.net/requests-mock/+bug/1584008

As a workaround I used

from urllib import parse
...
def text_callback(request, context):
    qs = parse.parse_qs(parse.urlparse(request.url).query)
vandoragroup commented 1 week ago

Looks like the problem originates here:

https://github.com/jamielennox/requests-mock/blob/9742d02a8cad17276dbeba7b300b6d27ae1b6fb1/requests_mock/request.py#L60-L61

Note the fixme that looks pretty old: https://github.com/jamielennox/requests-mock/blob/9742d02a8cad17276dbeba7b300b6d27ae1b6fb1/requests_mock/request.py#L42-L44

I'll try putting together a fix.