Skip to content
Myr

Response.fo => Reponse.raw

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

raise_for_status() fixes

authored by Kenneth Reitz · committed by Kenneth Reitz · parent 71d3490 · Browse files · 1 file+20 added−13 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+20 added−13 removed

  • other:+20 added−13 removed

1 file+20 added−13 removed

modified:requests/models.py+20 added-13 removed
16 unmodified lines
17from datetime import datetime181920from .packages import urllib321print dir(urllib3)21# print dir(urllib3)2223from .config import settings24from .monkeys import Request as _Request, HTTPBasicAuthHandler, HTTPForcedBasicAuthHandler, HTTPDigestAuthHandler, HTTPRedirectHandler25from .structures import CaseInsensitiveDict
163 unmodified lines
189 response.status_code = getattr(resp, 'status', None)190191 try:192 response.headers = CaseInsensitiveDict(getattr(resp, 'headers', None))193 # response.fo = resp193 response.raw = resp._raw194195 # if self.cookiejar:196197 # response.cookies = dict_from_cookiejar(self.cookiejar)
3 unmodified lines
201202 if is_error:203 response.error = resp204205 response.url = getattr(resp, 'url', None)206205 return response206207208 history = []209210211 r = build(resp)212213 if r.status_code in REDIRECT_STATI and not self.redirect:214
2 unmodified lines
217 ((r.status_code is codes.see_other) or218 (self.allow_redirects))219 ):220222 # r.fo.close()221 r.raw.close()222223 if not len(history) < settings.max_redirects:224 raise TooManyRedirects()225
105 unmodified lines
331 url=url,332 body=self.data,333 headers=self.headers,334 redirect=False,336 assert_same_host=False335 assert_same_host=False,336 block=True337 )338339 r.socket = pool._get_conn().sock339 # r.socket = pool._get_conn().sock340 # r.fo = r.data341342 # if self.cookiejar is not None:343 # self.cookiejar.extract_cookies(resp, req)344
123 unmodified lines
468 #: value of a ``'Content-Encoding'`` response header.469 self.headers = CaseInsensitiveDict()470471 #: File-like object representation of response (for advanced usage).471 self.fo = None472 self.raw = None473473 #: Final URL location of Response.474 self.url = None475474 #: True if no :attr:`error` occured.475 self.ok = False476477 #: Resulting :class:`HTTPError` of request, if one occured.
31 unmodified lines
509 'already consumed')510511 def generate():512 while 1:515 chunk = self.fo.read(chunk_size)513 chunk = self.raw.read(chunk_size)514 if not chunk:515 break516 yield chunk517 self._content_consumed = True
19 unmodified lines
537 raise RuntimeError('The content for this response was '538 'already consumed')539540 # Read the contents.543 self._content = self.fo.read()541 self._content = self.raw.read()542543 # Decode GZip'd content.544 if 'gzip' in self.headers.get('content-encoding', ''):545 try:
10 unmodified lines
556557558 def raise_for_status(self):559 """Raises stored :class:`HTTPError` or :class:`URLError`, if one occured."""560561 if self.error:562 raise self.error563564 if (self.status_code >= 300) and (self.status_code < 400):565 raise Exception('300 yo')566567 elif (self.status_code >= 400) and (self.status_code < 500):568 raise Exception('400 yo')569570 elif (self.status_code >= 500) and (self.status_code < 600):571 raise Exception('500 yo')572573574class AuthManager(object):575 """Requests Authentication Manager."""576577 def __new__(cls):
170 unmodified lines