POST with utf-8 not correctly catched
akhenakh opened this issue · 3 comments
akhenakh commented
The reason #31 does not work seems to be the same problem I have.
I worked on a httpie fork for oauth and httpie is building all requests with:
Content-Type: application/x-www-form-urlencoded; charset=utf-8
The following test in your code will not work correctly as it only test for equality with "Content-Type: application/x-www-form-urlencoded".
Then the POST data will disappear in the signature, here is a simple patch (one line) that's why I'm posting here.
diff --git a/oauth_hook/hook.py b/oauth_hook/hook.py
index b4042fd..3a85a8b 100644
--- a/oauth_hook/hook.py
+++ b/oauth_hook/hook.py
@@ -71,7 +71,7 @@ class OAuthHook(object):
"""
# See issues #10 and #12
if ('Content-Type' not in request.headers or \
- request.headers.get('Content-Type') == 'application/x-www-form-urlencoded') \
+ request.headers.get('Content-Type').startswith('application/x-www-form-urlencoded')) \
and not isinstance(request.data, basestring):
data_and_params = dict(request.data.items() + request.params.items())
prune998 commented
same issue here... Thanks for the patch !
maraujop commented
Thanks for the patch @akhenakh I've just merged it in and released version 0.4.1 in PyPi.
I've added you to AUTHORS. Great work with your OAuth httpie fork :D
Cheers,
Miguel
akhenakh commented
Thanks Miguel !