Skip to content
Myr

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

1 file+16 added−4 removed

modified:requests/core.py+16 added-4 removed
69 unmodified lines
70 self.headers = headers71 self.files = files72 self.method = method73 self.data = data74 7475 socket.setdefaulttimeout(timeout)7677 for (k, v) in self.data.iteritems():78 self.data[k] = v.encode('utf-8')7980 # 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.data8586 self.response = Response()8788 if isinstance(auth, (list, tuple)):
71 unmodified lines
160 pass161162 self.response.url = getattr(resp, 'url', None)163164165 @staticmethod162 def _build_url(url, data):166 def _build_url(url, data=None):167 """Build URLs."""168169 if urlparse(url).query:170 return '%s&%s' % (url, data)
2 unmodified lines
173 return '%s?%s' % (url, data)174 else:175 return url176177178 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 lines
207 if self.headers:208 req.headers.update(self.headers)209210 if not self.sent or anyway:211212213214 try:215 opener = self._get_opener()216 resp = opener(req)217
18 unmodified lines
236237 def read(self, *args):238 return self.response.read()239240241242class 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 lines
272 def read(self, *args):273 return self.content274275276277class AuthManager(object):278 """Authentication Manager."""279280 def __new__(cls):
28 unmodified lines
309 pass310311 self._auth[uri] = auth312313314 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