Encode incoming data.
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Closes #27.
authored by Kenneth Reitz · committed by Kenneth Reitz · parent 8a4a05a · Browse files · 1 file·+16 added−4 removed
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Diff stats
1 file+16 added−4 removed
- other:+16 added−4 removed
Provenance
- Commit
b6f6048- Tree
8a1d17a- Author
Kenneth Reitz <me@kennethreitz.com>- Committer
Kenneth Reitz <me@kennethreitz.com>- Parent
8a4a05a
1 file changed+16 added−4 removed
modified:requests/core.py+16 added-4 removed
69 unmodified lines70 self.headers = headers71 self.files = files72 self.method = method73 self.data = data74- 74+75 socket.setdefaulttimeout(timeout)76 77+ for (k, v) in self.data.iteritems():78+ self.data[k] = v.encode('utf-8')79+80 # url encode data if it's a dict81 if hasattr(data, 'items'):79- self._enc_data = urllib.urlencode(data)82+ self._enc_data = urllib.urlencode(self.data)83 else:81- self._enc_data = data84+ self._enc_data = self.data85 86 self.response = Response()87 88 if isinstance(auth, (list, tuple)):71 unmodified lines160 pass161 162 self.response.url = getattr(resp, 'url', None)163 164+165 @staticmethod162- def _build_url(url, data):166+ def _build_url(url, data=None):167 """Build URLs."""168 169 if urlparse(url).query:170 return '%s&%s' % (url, data)2 unmodified lines173 return '%s?%s' % (url, data)174 else:175 return url176 177+178 def send(self, anyway=False):179 """Sends the request. Returns True of successful, false if not.180 If there was an HTTPError during transmission,181 self.response.status_code will contain the HTTPError code.25 unmodified lines207 if self.headers:208 req.headers.update(self.headers)209 210 if not self.sent or anyway:211+212+213+214 try:215 opener = self._get_opener()216 resp = opener(req)217 18 unmodified lines236 237 def read(self, *args):238 return self.response.read()239 240+241+242 class Response(object):243 """The :class:`Request` object. All :class:`Request` objects contain a244 :class:`Request.response <response>` attribute, which is an instance of245 this class.26 unmodified lines272 def read(self, *args):273 return self.content274 275 276+277 class AuthManager(object):278 """Authentication Manager."""279 280 def __new__(cls):28 unmodified lines309 pass310 311 self._auth[uri] = auth312 313+314 def add_password(self, realm, uri, user, passwd):315 """Adds password to AuthManager."""316 # uri could be a single URI or a sequence317 if isinstance(uri, basestring):235 unmodified lines