Skip to content
Myr

Update reference to "cookielib" to "cookiejar" in documentation (#6214)

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

authored by Alexandre Erwin Ittner · committed by GitHub · parent fecf3dc · Browse files · 1 file+8 added−8 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+8 added−8 removed

  • other:+8 added−8 removed

1 file+8 added−8 removed

modified:requests/cookies.py+8 added-8 removed
1"""2requests.cookies3~~~~~~~~~~~~~~~~45Compatibility code to be able to use `cookielib.CookieJar` with requests.5Compatibility code to be able to use `http.cookiejar.CookieJar` with requests.67requests.utils imports from here, so be careful with imports.8"""9
12 unmodified lines
2223class MockRequest:24 """Wraps a `requests.Request` to mimic a `urllib2.Request`.2526 The code in `cookielib.CookieJar` expects this interface in order to correctly26 The code in `http.cookiejar.CookieJar` expects this interface in order to correctly27 manage cookie policies, i.e., determine whether a cookie can be set, given the28 domains of the request and the cookie.2930 The original request object is read-only. The client is responsible for collecting
44 unmodified lines
75 def get_header(self, name, default=None):76 return self._r.headers.get(name, self._new_headers.get(name, default))7778 def add_header(self, key, val):79 """cookielib has no legitimate use for this method; add it back if you find one."""79 """cookiejar has no legitimate use for this method; add it back if you find one."""80 raise NotImplementedError(81 "Cookie headers should be added with add_unredirected_header()"82 )83
19 unmodified lines
103class MockResponse:104 """Wraps a `httplib.HTTPMessage` to mimic a `urllib.addinfourl`.105106 ...what? Basically, expose the parsed HTTP headers from the server response107 the way `cookielib` expects to see them.107 the way `http.cookiejar` expects to see them.108 """109110 def __init__(self, headers):111 """Make a MockResponse for `cookielib` to read.111 """Make a MockResponse for `cookiejar` to read.112113 :param headers: a httplib.HTTPMessage or analogous carrying the headers114 """115 self._headers = headers
7 unmodified lines
123124def extract_cookies_to_jar(jar, request, response):125 """Extract the cookies from the response into a CookieJar.126127 :param jar: cookielib.CookieJar (not necessarily a RequestsCookieJar)127 :param jar: http.cookiejar.CookieJar (not necessarily a RequestsCookieJar)128 :param request: our own requests.Request object129 :param response: urllib3.HTTPResponse object130 """131 if not (hasattr(response, "_original_response") and response._original_response):
41 unmodified lines
173 """174175176class RequestsCookieJar(cookielib.CookieJar, MutableMapping):177 """Compatibility class; is a cookielib.CookieJar, but exposes a dict177 """Compatibility class; is a http.cookiejar.CookieJar, but exposes a dict178 interface.179180 This is the CookieJar we create by default for requests and sessions that181 don't specify one, since some clients may expect response.cookies and
158 unmodified lines
340 """341 self.set(name, value)342343 def __delitem__(self, name):344 """Deletes a cookie given a name. Wraps ``cookielib.CookieJar``'s344 """Deletes a cookie given a name. Wraps ``http.cookiejar.CookieJar``'s345 ``remove_cookie_by_name()``.346 """347 remove_cookie_by_name(self, name)348
213 unmodified lines