Skip to content
Myr

authors

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 c477f6e, c501784 · Browse files · 5 files+35 added−2 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

5 files+35 added−2 removed

  • tests:+21 added−0 removed
  • other:+14 added−2 removed

5 files+35 added−2 removed

modified:requests/api.py+1 added
23 unmodified lines
24 :param params: (optional) Dictionary or bytes to be sent in the query string for the :class:`Request`.25 :param data: (optional) Dictionary or bytes to send in the body of the :class:`Request`.26 :param headers: (optional) Dictionary of HTTP Headers to send with the :class:`Request`.27 :param cookies: (optional) Dict or CookieJar object to send with the :class:`Request`.28 :param store_cookies: (optional) if ``False``, the received cookies as part of the HTTP response would be ignored.29 :param files: (optional) Dictionary of 'name': file-like-objects (or {'name': ('filename', fileobj)}) for multipart encoding upload.30 :param auth: (optional) Auth tuple to enable Basic/Digest/Custom HTTP Auth.31 :param timeout: (optional) Float describing the timeout of the request.32 :param allow_redirects: (optional) Boolean. Set to True if POST/PUT/DELETE redirect following is allowed.
88 unmodified lines
modified:requests/models.py+7 added-2 removed
57 unmodified lines
58 data=dict(),59 params=dict(),60 auth=None,61 cookies=None,62 store_cookies=True,63 timeout=None,64 redirect=False,65 allow_redirects=False,66 proxies=None,
42 unmodified lines
109110 # Dictionary mapping protocol to the URL of the proxy (e.g. {'http': 'foo.bar:3128'})111 self.proxies = dict(proxies or [])112113 #param store_cookies: (optional) if ``False``, the received cookies as part of the HTTP response would be ignored.114 self.store_cookies = store_cookies115116 # If no proxies are given, allow configuration by environment variables117 # HTTP_PROXY and HTTPS_PROXY.118 if not self.proxies and self.config.get('trust_env'):119 self.proxies = get_environ_proxies()
79 unmodified lines
199200 # Set encoding.201 response.encoding = get_encoding_from_headers(response.headers)202199 # Add new cookies from the server.200 extract_cookies_to_jar(self.cookies, self, resp)203 # Add new cookies from the server. Don't if configured not to204 if self.store_cookies:205 extract_cookies_to_jar(self.cookies, self, resp)206207 # Save cookies in Response.208 response.cookies = self.cookies209
626 unmodified lines
modified:requests/sessions.py+5 added
58 unmodified lines
5960 def __init__(self,61 headers=None,62 cookies=None,63 store_cookies=True,64 auth=None,65 timeout=None,66 proxies=None,67 hooks=None,
12 unmodified lines
80 self.config = config or {}81 self.prefetch = prefetch82 self.verify = verify83 self.cert = cert84 self.store_cookies = store_cookies8586 for (k, v) in list(defaults.items()):87 self.config.setdefault(k, deepcopy(v))88
24 unmodified lines
113 params=None,114 data=None,115 headers=None,116 cookies=None,117 store_cookies=True,118 files=None,119 auth=None,120 timeout=None,121 allow_redirects=True,
13 unmodified lines
135 :param params: (optional) Dictionary or bytes to be sent in the query string for the :class:`Request`.136 :param data: (optional) Dictionary or bytes to send in the body of the :class:`Request`.137 :param headers: (optional) Dictionary of HTTP Headers to send with the :class:`Request`.138 :param cookies: (optional) Dict or CookieJar object to send with the :class:`Request`.139 :param store_cookies: (optional) if ``False``, the received cookies as part of the HTTP response would be ignored.140 :param files: (optional) Dictionary of 'filename': file-like-objects for multipart encoding upload.141 :param auth: (optional) Auth tuple or callable to enable Basic/Digest/Custom HTTP Auth.142 :param timeout: (optional) Float describing the timeout of the request.143 :param allow_redirects: (optional) Boolean. Set to True by default.
30 unmodified lines
174 data=data,175 params=params,176 headers=headers,177 cookies=cookies,178 store_cookies=store_cookies,179 files=files,180 auth=auth,181 hooks=hooks,182 timeout=timeout,
147 unmodified lines
modified:tests/test_cookies.py+21 added
100 unmodified lines
101 insecure_resp = requests.get('http://httpbin.org/cookies', cookies=cookies)102 insecure_cookies_sent = json.loads(insecure_resp.text)['cookies']103 self.assertEqual(insecure_cookies_sent, {})104105 def test_disabled_cookie_persistence(self):106 """Test that cookies are not persisted when configured accordingly."""107108 # Check the case when no cookie is passed as part of the request and the one in response is ignored109 cookies = requests.get(httpbin('cookies', 'set', 'key', 'value'), store_cookies = False).cookies110 self.assertIsNone(cookies.get("key"))111112 # Test that the cookies passed while making the request still gets used and is available in response object.113 # only the ones received from server is not saved114 cookies_2 = requests.get(httpbin('cookies', 'set', 'key', 'value'), store_cookies = False,\115 cookies = {"key_2" : "value_2"}).cookies116 self.assertEqual(len(cookies_2), 1)117 self.assertEqual(cookies_2.get("key_2"), "value_2")118119 # Use the session and make sure that the received cookie is not used in subsequent calls120 s = requests.session()121 s.get(httpbin('cookies', 'set', 'key', 'value'), store_cookies = False)122 r = s.get(httpbin('cookies'))123 self.assertEqual(json.loads(r.text)['cookies'], {})124125126class LWPCookieJarTest(TestBaseMixin, unittest.TestCase):127 """Check store/load of cookies to FileCookieJar's, specifically LWPCookieJar's."""128129 COOKIEJAR_CLASS = cookielib.LWPCookieJar
99 unmodified lines
modified:AUTHORS.rst+1 added
99 unmodified lines
100- Rohan Jain (crodjer)101- Justin Barber <barber.justin@gmail.com>102- Roman Haritonov <@reclosedev>103- Josh Imhoff <joshimhoff13@gmail.com>104- Arup Malakar <amalakar@gmail.com>