Skip to content
Myr

CaseInsensitiveDict for Headers

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 29aa773 · Browse files · 1 file+5 added−8 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+5 added−8 removed

  • other:+5 added−8 removed

1 file+5 added−8 removed

modified:requests/models.py+5 added-8 removed
14 unmodified lines
15from urllib2 import HTTPError16from urlparse import urlparse1718from .monkeys import Request as _Request, HTTPBasicAuthHandler, HTTPDigestAuthHandler1919from .structures import CaseInsensitiveDict20from .packages.poster.encode import multipart_encode21from .packages.poster.streaminghttp import register_openers, get_handlers2223
95 unmodified lines
119 return opener.open120121 def _build_response(self, resp):122 """Build internal Response object from given response."""123 if isinstance(resp, HTTPError):124 # print resp.__dict__125 pass123124 self.response.status_code = getattr(resp, 'code', None)125126 try:130 self.response.headers = getattr(resp.info(), 'dict', None)127 self.response.headers = CaseInsensitiveDict(getattr(resp.info(), 'dict', None))128 self.response.content = resp.read()132 except AttributeError, why:129 except AttributeError:130 pass131135 if self.response.headers.get('content-encoding', None) == 'gzip':132 if self.response.headers['content-encoding'] == 'gzip':133 try:134 self.response.content = zlib.decompress(self.response.content, 16+zlib.MAX_WBITS)135 except zlib.error:136 pass
84 unmodified lines
221222 def __init__(self):223 self.content = None224 self.status_code = None228 self.headers = dict()225 self.headers = CaseInsensitiveDict()226 self.url = None227 self.ok = False228 self.error = None229 self.cached = False
203 unmodified lines