From: Kenneth Reitz Date: Tue, 1 May 2012 10:42:58 +0000 (-0400) Subject: Revert "Call auth callable before encoding body data" X-Git-Tag: v0.12.0~30 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=be04142723c7d67355a748ae944d01194c299909;p=services%2Fpython-requests.git Revert "Call auth callable before encoding body data" This reverts commit 9217a2523d7d4fafeebb259884276fc349a376b1. --- diff --git a/requests/models.py b/requests/models.py index 1ba1c3e..fe2ffa9 100644 --- a/requests/models.py +++ b/requests/models.py @@ -481,6 +481,22 @@ class Request(object): body = None content_type = None + # Multi-part file uploads. + if self.files: + (body, content_type) = self._enc_files + else: + if self.data: + + body = self._enc_data + if isinstance(self.data, str): + content_type = None + else: + content_type = 'application/x-www-form-urlencoded' + + # Add content-type if it wasn't explicitly provided. + if (content_type) and (not 'content-type' in self.headers): + self.headers['Content-Type'] = content_type + # Use .netrc auth if none was provided. if not self.auth and self.config.get('trust_env'): self.auth = get_netrc_auth(url) @@ -496,21 +512,6 @@ class Request(object): # Update self to reflect the auth changes. self.__dict__.update(r.__dict__) - # Multi-part file uploads. - if self.files: - (body, content_type) = self._enc_files - else: - if self.data: - body_params, body = self._encode_params(self.data) - if isinstance(body_params, list) and isinstance(body, str): - content_type = 'application/x-www-form-urlencoded' - else: - content_type = None - - # Add content-type if it wasn't explicitly provided. - if (content_type) and (not 'content-type' in self.headers): - self.headers['Content-Type'] = content_type - _p = urlparse(url) proxy = self.proxies.get(_p.scheme)