@@ -600,15 +600,19 @@ def set_signature_method(self, method):
600
600
601
601
def request (self , uri , method = "GET" , body = None , headers = None ,
602
602
redirections = httplib2 .DEFAULT_MAX_REDIRECTS , connection_type = None ):
603
- DEFAULT_CONTENT_TYPE = 'application/x-www-form-urlencoded'
603
+ DEFAULT_POST_CONTENT_TYPE = 'application/x-www-form-urlencoded'
604
604
605
605
if not isinstance (headers , dict ):
606
606
headers = {}
607
607
608
- is_multipart = method == 'POST' and headers .get ('Content-Type' ,
609
- DEFAULT_CONTENT_TYPE ) != DEFAULT_CONTENT_TYPE
608
+ if method == "POST" :
609
+ headers ['Content-Type' ] = headers .get ('Content-Type' ,
610
+ DEFAULT_POST_CONTENT_TYPE )
610
611
611
- if body and method == "POST" and not is_multipart :
612
+ is_form_encoded = \
613
+ headers .get ('Content-Type' ) == 'application/x-www-form-urlencoded'
614
+
615
+ if is_form_encoded and body :
612
616
parameters = dict (parse_qsl (body ))
613
617
else :
614
618
parameters = None
@@ -620,12 +624,10 @@ def request(self, uri, method="GET", body=None, headers=None,
620
624
req .sign_request (self .method , self .consumer , self .token )
621
625
622
626
if method == "POST" :
623
- headers ['Content-Type' ] = headers .get ('Content-Type' ,
624
- DEFAULT_CONTENT_TYPE )
625
- if is_multipart :
626
- headers .update (req .to_header ())
627
- else :
627
+ if is_form_encoded :
628
628
body = req .to_postdata ()
629
+ else :
630
+ headers .update (req .to_header ())
629
631
elif method == "GET" :
630
632
uri = req .to_url ()
631
633
else :
0 commit comments