Skip to content
Myr

accept any extra args to r.read()

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Kenneth Reitz · committed by Kenneth Reitz · parent cc16073 · Browse files · 1 file+17 added−17 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+17 added−17 removed

  • other:+17 added−17 removed

1 file+17 added−17 removed

modified:requests/core.py+17 added-17 removed
29 unmodified lines
30__license__ = 'ISC'31__copyright__ = 'Copyright 2011 Kenneth Reitz'3233__all__ = [34 'Request', 'Response', 'request', 'get', 'head', 'post', 'put', 'delete', 35 'auth_manager', 'AuthObject','RequestException', 'AuthenticationError', 34 'Request', 'Response', 'request', 'get', 'head', 'post', 'put', 'delete',35 'auth_manager', 'AuthObject','RequestException', 'AuthenticationError',36 'URLRequired', 'InvalidMethod', 'HTTPError'37]3839
22 unmodified lines
62 _METHODS = ('GET', 'HEAD', 'PUT', 'POST', 'DELETE')6364 def __init__(self, url=None, headers=dict(), files=None, method=None,65 data=dict(), auth=None, cookiejar=None):66 6667 self.url = url68 self.headers = headers69 self.files = files70 self.method = method
69 unmodified lines
140 return opener.open141142 def _build_response(self, resp):143 """Build internal Response object from given response."""144 144145 self.response.status_code = getattr(resp, 'code', None)146 self.response.headers = getattr(resp.info(), 'dict', None)147 self.response.url = getattr(resp, 'url', None)148 self.response.content = resp.read()
1 unmodified line
150151 @staticmethod152 def _build_url(url, data):153 """Build URLs."""154 154155 if urlparse(url).query:156 return '%s&%s' % (url, data)157 else:158 if data:
22 unmodified lines
181 register_openers()182183 if self.data:184 self.files.update(self.data)185 185186 datagen, headers = multipart_encode(self.files)187 req = _Request(self.url, data=datagen, headers=headers, method=self.method)188 188189 else:190 req = _Request(self.url, data=self._enc_data, method=self.method)191192 if self.headers:
5 unmodified lines
198 resp = opener(req)199200 if self.cookiejar is not None:201 self.cookiejar.extract_cookies(resp, req)202 202203 except urllib2.HTTPError, why:204 self._build_response(why)205 self.response.error = why206 else:
8 unmodified lines
215216 return self.sent217218219 def read(self):219 def read(self, *args):220 return self.response.read()221 221222class Response(object):223 """The :class:`Request` object. All :class:`Request` objects contain a224 :class:`Request.response <response>` attribute, which is an instance of225 this class.
22 unmodified lines
248 """Raises stored HTTPError if one exists."""249 if self.error:250 raise self.error251252 def read(self):252 def read(self, *args):253 return self.content254255256class AuthManager(object):257 """Authentication Manager."""258 258259 def __new__(cls):260 singleton = cls.__dict__.get('__singleton__')261 if singleton is not None:262 return singleton
13 unmodified lines
276277278 def add_auth(self, uri, auth):279 """Registers AuthObject to AuthManager."""280 280281 uri = self.reduce_uri(uri, False)282 self._auth[uri] = auth283284 def add_password(self, realm, uri, user, passwd):285 """Adds password to AuthManager."""286 # uri could be a single URI or a sequence287 if isinstance(uri, basestring):288 uri = [uri]289 289290 reduced_uri = tuple([self.reduce_uri(u, False) for u in uri])291 291292 if reduced_uri not in self.passwd:293 self.passwd[reduced_uri] = {}294 self.passwd[reduced_uri] = (user, passwd)295
35 unmodified lines
331 if dport is not None:332 authority = "%s:%d" % (host, dport)333 return authority, path334335 335336 def is_suburi(self, base, test):337 """Check if test is below base in a URI tree338339 Both args must be URIs in reduced form.
100 unmodified lines
440 :param headers: (optional) Dictionary of HTTP Headers to send with the :class:`Request`.441 :param cookies: (optional) CookieJar object to send with the :class:`Request`.442 :param auth: (optional) AuthObject to enable Basic HTTP Auth.443 """444 444445 return request('GET', url, params=params, headers=headers, cookies=cookies, auth=auth)446447448def head(url, params={}, headers={}, cookies=None, auth=None):
66 unmodified lines