dict(o or [])
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 0f2dcff · Browse files · 1 file·+25 added−23 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+25 added−23 removed
- other:+25 added−23 removed
Provenance
- Commit
35ed9b5- Tree
e939f80- Author
Kenneth Reitz <me@kennethreitz.com>- Committer
Kenneth Reitz <me@kennethreitz.com>- Parent
0f2dcff
1 file changed+25 added−23 removed
modified:requests/models.py+25 added-23 removed
59 unmodified lines60 #: Request URL.61 self.url = url62 63 #: Dictionary of HTTP Headers to attach to the :class:`Request <Request>`.64- self.headers = headers64+ self.headers = dict(headers or [])65 66 #: Dictionary of files to multipart upload (``{filename: content}``).67 self.files = files68 15 unmodified lines84 #: Set to True if full redirects are allowed (e.g. re-POST-ing of data at new ``Location``)85 self.allow_redirects = allow_redirects86 87 # Dictionary mapping protocol to the URL of the proxy (e.g. {'http': 'foo.bar:3128'})88- self.proxies = proxies88+ self.proxies = dict(proxies or [])89 90 self.data, self._enc_data = self._encode_params(data)91 self.params, self._enc_params = self._encode_params(params)92 5 unmodified lines98 self._auth = auth99 self.auth = auth_dispatch(auth)100 101 #: CookieJar to attach to :class:`Request <Request>`.102- self.cookies = cookies102+ self.cookies = dict(cookies or [])103 104 #: Dictionary of configurations for this request.105- self.config = config105+ self.config = dict(config or [])106 107 #: True if Request has been sent.108 self.sent = False109 33 unmodified lines143 144 # Pass settings over.145 response.config = self.config146 147- # Fallback to None if there's no staus_code, for whatever reason.148- response.status_code = getattr(resp, 'status', None)147+ if resp:148 150- # Make headers case-insensitive.151- response.headers = CaseInsensitiveDict(getattr(resp, 'headers', None))149+ # Fallback to None if there's no staus_code, for whatever reason.150+ response.status_code = getattr(resp, 'status', None)151 153- # Start off with our local cookies.154- cookies = self.cookies or dict()152+ # Make headers case-insensitive.153+ response.headers = CaseInsensitiveDict(getattr(resp, 'headers', None))154 156- # Add new cookies from the server.157- if 'set-cookie' in response.headers:158- cookie_header = response.headers['set-cookie']155+ # Start off with our local cookies.156+ cookies = self.cookies or dict()157 160- c = SimpleCookie()161- c.load(cookie_header)158+ # Add new cookies from the server.159+ if 'set-cookie' in response.headers:160+ cookie_header = response.headers['set-cookie']161 163- for k,v in c.items():164- cookies.update({k: v.value})162+ c = SimpleCookie()163+ c.load(cookie_header)164 166- # Save cookies in Response.167- response.cookies = cookies165+ for k,v in c.items():166+ cookies.update({k: v.value})167 168+ # Save cookies in Response.169+ response.cookies = cookies170+171 # Save original resopnse for later.172 response.raw = resp173 174 if is_error:209 unmodified lines384 decode_content=False,385 retries=self.config.get('max_retries', 0)386 )387 except MaxRetryError, e:386- if self.config.get('safe_mode', False):387- pass388- raise ConnectionError(e)388+ if not self.config.get('safe_mode', False):389+ raise ConnectionError(e)390+ else:391+ r = None392 390-393 self._build_response(r)394 395 # Response manipulation hook.396 self.response = dispatch_hook('response', self.hooks, self.response)152 unmodified lines