Merge branch 'develop' of https://github.com/robmadole/requests into develop
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 · parents 1d021c5, e4c690e · Browse files · 3 files·+21 added−4 removed
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Diff stats
3 files+21 added−4 removed
- other:+21 added−4 removed
Provenance
- Commit
fa2f1c5- Tree
319186a- Author
Kenneth Reitz <me@kennethreitz.com>- Committer
Kenneth Reitz <me@kennethreitz.com>- Parent 1
1d021c5- Parent 2
e4c690e
3 files changed+21 added−4 removed
modified:requests/core.py+9 added-3 removed
109 unmodified lines110 """Creates appropriate opener object for urllib2."""111 112 _handlers = []113 114+ if self.cookiejar != None:115+ _handlers.append(urllib2.HTTPCookieProcessor(self.cookiejar))116+117 if self.auth:118 if not isinstance(self.auth.handler, (urllib2.AbstractBasicAuthHandler, urllib2.AbstractDigestAuthHandler)):119 auth_manager.add_password(self.auth.realm, self.url, self.auth.username, self.auth.password)120 self.auth.handler = self.auth.handler(auth_manager)121 auth_manager.add_auth(self.url, self.auth)122 123 _handlers.append(self.auth.handler)124 125+ if _handlers:126 _handlers.extend(get_handlers())127 opener = urllib2.build_opener(*_handlers)128 return opener.open129 else:56 unmodified lines186 187 if not self.sent or anyway:188 try:189 opener = self._get_opener()186- resp = opener(req)190+ resp = opener(req)191+192+ if self.cookiejar != None:193+ self.cookiejar.extract_cookies(resp, req)194 except urllib2.HTTPError, why:195 self._build_response(why)196 self.response.error = why197 else:3 unmodified lines201 self.response.cached = False202 else:203 self.response.cached = True204 198-205 self.sent = self.response.ok206 207 return self.sent208 202 unmodified lines411 """412 data = kwargs.pop('data', dict()) or kwargs.pop('params', dict())413 414 r = Request(method=method, url=url, data=data, headers=kwargs.pop('headers', {}),409- cookiejar=kwargs.pop('cookies', None), files=kwargs.pop('files', None),415+ cookiejar=kwargs.pop('cookiejar', None), files=kwargs.pop('files', None),416 auth=kwargs.pop('auth', auth_manager.get_auth(url)))417 r.send()418 419 return r.response82 unmodified linesmodified:.gitignore+2 added-1 removed
1 .idea2 MANIFEST3 coverage.xml4 nosetests.xml5-pylint.txt5+pylint.txt6+*.pycmodified:test_requests.py+10 added
1 #!/usr/bin/env python2 # -*- coding: utf-8 -*-3 4 import unittest5+import cookielib6 7 import requests8 9 104 unmodified lines114 r = requests.get('http://google.com/')115 self.assertFalse(r.error)116 r.raise_for_status()117 118+ def test_cookie_jar(self):119+ """120+ .. todo:: This really doesn't test to make sure the cookie is working121+ """122+ jar = cookielib.CookieJar()123+ self.assertFalse(jar)124 125+ requests.get('http://google.com', cookies=jar)126+ self.assertTrue(jar)127 128 129+130 if __name__ == '__main__':131 unittest.main()