From d83ae2f834aa26e7454618ea253ef62b1412dc31 Mon Sep 17 00:00:00 2001 From: nickspring Date: Sun, 23 Nov 2014 23:40:31 +0100 Subject: [PATCH 1/4] Upload file bug with oauth signing was fixed It was a mistake to set content-type = application/x-www-form-urlencoded by default, requests lib setup it dynamically if we have non-empty parameter "files". Original version didn't work with images (files) upload for example in Etsy API see https://www.etsy.com/developers/documentation/getting_started/images --- rauth/session.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rauth/session.py b/rauth/session.py index 089854f..9933e81 100644 --- a/rauth/session.py +++ b/rauth/session.py @@ -149,7 +149,7 @@ def request(self, url = self._set_url(url) entity_method = method.upper() in ENTITY_METHODS - if entity_method: + if entity_method and 'files' not in req_kwargs or req_kwargs['files'] is None: req_kwargs['headers'].setdefault('Content-Type', FORM_URLENCODED) form_urlencoded = \ From 0492e4cbd141e8e6bd6f7271b941cc79a3f57a4b Mon Sep 17 00:00:00 2001 From: nickspring Date: Mon, 24 Nov 2014 22:35:57 +0100 Subject: [PATCH 2/4] Change format --- rauth/session.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/rauth/session.py b/rauth/session.py index 9933e81..26b9222 100644 --- a/rauth/session.py +++ b/rauth/session.py @@ -149,7 +149,8 @@ def request(self, url = self._set_url(url) entity_method = method.upper() in ENTITY_METHODS - if entity_method and 'files' not in req_kwargs or req_kwargs['files'] is None: + if entity_method and 'files' not in req_kwargs or \ + req_kwargs['files'] is None: req_kwargs['headers'].setdefault('Content-Type', FORM_URLENCODED) form_urlencoded = \ From 2544a018429f16a9e849c60c21525ebfced303be Mon Sep 17 00:00:00 2001 From: Yarovoy Nikolay Date: Sat, 20 Dec 2014 20:40:58 +0100 Subject: [PATCH 3/4] E125 continuation line with same indent as next logical line was fixed --- rauth/session.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rauth/session.py b/rauth/session.py index 26b9222..87d5c1e 100644 --- a/rauth/session.py +++ b/rauth/session.py @@ -150,7 +150,7 @@ def request(self, entity_method = method.upper() in ENTITY_METHODS if entity_method and 'files' not in req_kwargs or \ - req_kwargs['files'] is None: + req_kwargs['files'] is None: req_kwargs['headers'].setdefault('Content-Type', FORM_URLENCODED) form_urlencoded = \ From 5db4c9589dbd0536b4716b6d225f8ddffb4d8ebc Mon Sep 17 00:00:00 2001 From: Yarovoy Nikolay Date: Sat, 20 Dec 2014 21:03:29 +0100 Subject: [PATCH 4/4] fix formating --- rauth/session.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/rauth/session.py b/rauth/session.py index 87d5c1e..916f3d5 100644 --- a/rauth/session.py +++ b/rauth/session.py @@ -150,8 +150,8 @@ def request(self, entity_method = method.upper() in ENTITY_METHODS if entity_method and 'files' not in req_kwargs or \ - req_kwargs['files'] is None: - req_kwargs['headers'].setdefault('Content-Type', FORM_URLENCODED) + req_kwargs['files'] is None: + req_kwargs['headers'].setdefault('Content-Type', FORM_URLENCODED) form_urlencoded = \ req_kwargs['headers'].get('Content-Type') == FORM_URLENCODED