vcrpy icon indicating copy to clipboard operation
vcrpy copied to clipboard

When filtering post data, handle ContentType with specified charset (ex: 'application/json;charset=UTF-8')

Open poussik opened this issue 8 years ago • 5 comments

Hello,

Regarding the website Amundi.com, I was unable to filter the POST data username & password. The Content-Type set is "application/json;charset=UTF-8", so strict comparison with "application/json" is not possible.

Thanks for this great python module!

poussik avatar May 09 '17 10:05 poussik

FYI json must be in UTF8, so that flag is redundant.

Matching the prefix is also incorrect, because it would include application/json-not-really-json

graingert avatar May 09 '17 19:05 graingert

Maybe https://pypi.python.org/pypi/python-mimeparse will help

graingert avatar May 09 '17 19:05 graingert

Hi,

Probably you read too quickly so you misunderstood the patch, FYI d.get(X, '') returns None when d[X] == None. Regarding mimeparse I do not think adding a dependency for a so much small problem is a good idea. I have updated this PR using standard cgi module (like mimeparse), and kept the logic as it was before.

Imho the best way to do would be to try except a json.loads instead of relying on Content-Type, but it is not aligned with the coding style.

poussik avatar May 10 '17 08:05 poussik

Hello @graingert , The last build has failed because of a flickr timeout, can you please relaunch it ?

poussik avatar May 11 '17 08:05 poussik

@poussik thanks for your PR! Sorry for the delay, but your propose really makes sense.

Can you update your branch so we can follow with the review/merge process? :slightly_smiling_face:

lamenezes avatar May 03 '18 15:05 lamenezes