Skip to content
Myr

requests cookies behaving

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 14bd9eb · Browse files · 2 files+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

2 files+20 added−13 removed

  • other:+20 added−13 removed

2 files+20 added−13 removed

modified:requests/models.py+2 added-10 removed
162 unmodified lines
163 history = []164165 # Create the lone response object.166 r = build(resp)167 self.cookies.update(r.cookies)168169 # Store the HTTP response, just in case.170 r._response = resp171
64 unmodified lines
236237 # Send her away!238 request.send()239 r = request.response240 self.cookies.update(r.cookies)241242 # Insert collected history.243 r.history = history244
100 unmodified lines
345 # Set the pools manager for redirections, if allowed.346 if self.config.get('keepalive') and pools:347 self._pools = pools348347 # Extract cookies.348 if self.cookies is not None:349 pass350 # cookies = cookiejar_from_dict(self.cookies)351# >>> C = Cookie.SimpleCookie()352# >>> C["rocky"] = "road"353# >>> C["rocky"]["path"] = "/cookie"354# >>> print C.output(header="Cookie:")355# Cookie: rocky=road; Path=/cookie356 # self.cookiejar.extract_cookies(resp, req)349350 # except (urllib2.HTTPError, urllib2.URLError), why:351 except Exception, why:352 print why.__dict__
148 unmodified lines
modified:requests/sessions.py+18 added-3 removed
56 unmodified lines
57 hooks=None,58 config=None):5960 self.headers = headers61 self.cookies = cookies61 self.cookies = cookies or {}62 self.auth = auth63 self.timeout = timeout64 self.proxies = proxies65 self.hooks = hooks
29 unmodified lines
95 _kwargs = {}9697 # Merge local and session arguments.98 for attr in self.__attrs__:99 # if attr == 'cookies':100 # print getattr(self, attr)101 # print kwargs.get(attr)102103 # Merge local and session dictionaries.104 default_attr = getattr(self, attr)105 local_attr = kwargs.get(attr)106102 # Merge local and session dictionaries.107 # Cookies persist.108 if attr == 'cookies':109 local_attr = local_attr or {}110111 new_attr = merge_kwargs(local_attr, default_attr)112113 # Skip attributes that were set to None.114 if new_attr is not None:
8 unmodified lines
123 if self.config.get('keepalive'):124 _kwargs['_pools'] = self.__pools125126 # TODO: Persist cookies.127 # print self.cookies128129 # print _kwargs.get('cookies')130 # print '%%%'131120 return func(*args, **_kwargs)132 r = func(*args, **_kwargs)133 # print r.cookies134 self.cookies.update(r.cookies)135 return r136 return wrapper_func137138 # Map and decorate each function available in requests.api139 map(lambda fn: setattr(self, fn, pass_args(getattr(api, fn))), api.__all__)
6 unmodified lines