Skip to content
Myr

Added CookieJar

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 cde3b88 · Browse files · 1 file+19 added−6 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+19 added−6 removed

  • other:+19 added−6 removed

1 file+19 added−6 removed

modified:requests/core.py+19 added-6 removed
71 unmodified lines
72 self.method = None73 self.params = {}74 self.data = {}75 self.response = Response()76 77 self.auth = None78 self.cookiejar = None79 self.sent = False80 81 82 def __repr__(self):
16 unmodified lines
99100 101 def _get_opener(self):102 """Creates appropriate opener object for urllib2."""101 103104 _handlers = []105106 if self.auth:107108 # create a password manager109 authr = urllib2.HTTPPasswordMgrWithDefaultRealm()110111 authr.add_password(None, self.url, self.auth.username, self.auth.password)108 handler = urllib2.HTTPBasicAuthHandler(authr)109 opener = urllib2.build_opener(handler)112 auth_handler = urllib2.HTTPBasicAuthHandler(authr)113114 _handlers.append(auth_handler)115116 # use the opener to fetch a URL112 return opener.open113 else:114 return urllib2.urlopen117# return opener.open118 if self.cookiejar:119 120 cookie_handler = urllib2.HTTPCookieProcessor(cookiejar)121 _handlers.append(cookie_handler)122123 opener = urllib2.build_opener(*_handlers)124125 return opener.open126# else:127# return urllib2.urlopen128129130 def _build_response(self, resp):131 """Build internal Response object from given response."""132 133 self.response.status_code = resp.code
319 unmodified lines