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
Provenance
- Commit
23d5761- Tree
7a4526a- Author
Kenneth Reitz <me@kennethreitz.com>- Committer
Kenneth Reitz <me@kennethreitz.com>- Parent
cc16073
1 file changed+17 added−17 removed
modified:requests/core.py+17 added-17 removed
29 unmodified lines30 __license__ = 'ISC'31 __copyright__ = 'Copyright 2011 Kenneth Reitz'32 33 __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 ]38 39 22 unmodified lines62 _METHODS = ('GET', 'HEAD', 'PUT', 'POST', 'DELETE')63 64 def __init__(self, url=None, headers=dict(), files=None, method=None,65 data=dict(), auth=None, cookiejar=None):66- 66+67 self.url = url68 self.headers = headers69 self.files = files70 self.method = method69 unmodified lines140 return opener.open141 142 def _build_response(self, resp):143 """Build internal Response object from given response."""144- 144+145 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 line150 151 @staticmethod152 def _build_url(url, data):153 """Build URLs."""154- 154+155 if urlparse(url).query:156 return '%s&%s' % (url, data)157 else:158 if data:22 unmodified lines181 register_openers()182 183 if self.data:184 self.files.update(self.data)185- 185+186 datagen, headers = multipart_encode(self.files)187 req = _Request(self.url, data=datagen, headers=headers, method=self.method)188- 188+189 else:190 req = _Request(self.url, data=self._enc_data, method=self.method)191 192 if self.headers:5 unmodified lines198 resp = opener(req)199 200 if self.cookiejar is not None:201 self.cookiejar.extract_cookies(resp, req)202- 202+203 except urllib2.HTTPError, why:204 self._build_response(why)205 self.response.error = why206 else:8 unmodified lines215 216 return self.sent217 218 219- def read(self):219+ def read(self, *args):220 return self.response.read()221- 221+222 class 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 lines248 """Raises stored HTTPError if one exists."""249 if self.error:250 raise self.error251 252- def read(self):252+ def read(self, *args):253 return self.content254 255 256 class AuthManager(object):257 """Authentication Manager."""258- 258+259 def __new__(cls):260 singleton = cls.__dict__.get('__singleton__')261 if singleton is not None:262 return singleton13 unmodified lines276 277 278 def add_auth(self, uri, auth):279 """Registers AuthObject to AuthManager."""280- 280+281 uri = self.reduce_uri(uri, False)282 self._auth[uri] = auth283 284 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- 289+290 reduced_uri = tuple([self.reduce_uri(u, False) for u in uri])291- 291+292 if reduced_uri not in self.passwd:293 self.passwd[reduced_uri] = {}294 self.passwd[reduced_uri] = (user, passwd)295 35 unmodified lines331 if dport is not None:332 authority = "%s:%d" % (host, dport)333 return authority, path334 335- 335+336 def is_suburi(self, base, test):337 """Check if test is below base in a URI tree338 339 Both args must be URIs in reduced form.100 unmodified lines440 :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- 444+445 return request('GET', url, params=params, headers=headers, cookies=cookies, auth=auth)446 447 448 def head(url, params={}, headers={}, cookies=None, auth=None):66 unmodified lines