Files
PowerToys/PythonHome/Lib/site-packages/requests/cookies.pyc

163 lines
21 KiB
Plaintext
Raw Normal View History

2014-07-09 18:15:23 +08:00
<03>
2014-07-10 23:57:08 +08:00
l<EFBFBD><EFBFBD>Sc@s$dZddlZddlZddlmZmZmZmZyddlZeWne k
2014-07-09 18:15:23 +08:00
rsddl
ZnXde fd<00><00>YZ de fd<00><00>YZ d <00>Zd
<00>Zddd <00>Zd efd <00><00>YZdejejfd<00><00>YZd<00>Zd<00>Zded<00>Zd<00>ZdS(s<>
Compatibility code to be able to use `cookielib.CookieJar` with requests.
requests.utils imports from here, so be careful with imports.
i<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ni(t cookielibturlparset
urlunparsetMorselt MockRequestcBs<>eZdZd<00>Zd<00>Zd<00>Zd<00>Zd<00>Zd<00>Zd<00>Z dd<00>Z d <00>Z d
<00>Z d <00>Zed <00><00>Zed <00><00>Zed<00><00>ZRS(s<>Wraps a `requests.Request` to mimic a `urllib2.Request`.
The code in `cookielib.CookieJar` expects this interface in order to correctly
manage cookie policies, i.e., determine whether a cookie can be set, given the
domains of the request and the cookie.
The original request object is read-only. The client is responsible for collecting
the new headers via `get_new_headers()` and interpreting them appropriately. You
probably want `get_cookie_header`, defined below.
2014-07-10 23:57:08 +08:00
cCs.||_i|_t|jj<00>j|_dS(N(t_rt _new_headersRturltschemettype(tselftrequest((sSe:\github\Wox.JSONRPC\Output\Debug\PythonHome\lib\site-packages\requests\cookies.pyt__init__!s  cCs|jS(N(R (R
((sSe:\github\Wox.JSONRPC\Output\Debug\PythonHome\lib\site-packages\requests\cookies.pytget_type&scCst|jj<00>jS(N(RRRtnetloc(R
((sSe:\github\Wox.JSONRPC\Output\Debug\PythonHome\lib\site-packages\requests\cookies.pytget_host)scCs
2014-07-09 18:15:23 +08:00
|j<00>S(N(R(R
2014-07-10 23:57:08 +08:00
((sSe:\github\Wox.JSONRPC\Output\Debug\PythonHome\lib\site-packages\requests\cookies.pytget_origin_req_host,scCsl|jjjd<00>s|jjS|jjd}t|jj<00>}t|j||j|j|j |j
2014-07-09 18:15:23 +08:00
g<00>S(NtHost( RtheaderstgetRRRRtpathtparamstquerytfragment(R
2014-07-10 23:57:08 +08:00
thosttparsed((sSe:\github\Wox.JSONRPC\Output\Debug\PythonHome\lib\site-packages\requests\cookies.pyt get_full_url/s
2014-07-09 18:15:23 +08:00
cCstS(N(tTrue(R
2014-07-10 23:57:08 +08:00
((sSe:\github\Wox.JSONRPC\Output\Debug\PythonHome\lib\site-packages\requests\cookies.pytis_unverifiable=scCs||jjkp||jkS(N(RRR(R
tname((sSe:\github\Wox.JSONRPC\Output\Debug\PythonHome\lib\site-packages\requests\cookies.pyt
2014-07-09 18:15:23 +08:00
has_header@scCs%|jjj||jj||<00><00>S(N(RRRR(R
2014-07-10 23:57:08 +08:00
Rtdefault((sSe:\github\Wox.JSONRPC\Output\Debug\PythonHome\lib\site-packages\requests\cookies.pyt
2014-07-09 18:15:23 +08:00
get_headerCscCstd<00><00>dS(sMcookielib has no legitimate use for this method; add it back if you find one.s=Cookie headers should be added with add_unredirected_header()N(tNotImplementedError(R
2014-07-10 23:57:08 +08:00
tkeytval((sSe:\github\Wox.JSONRPC\Output\Debug\PythonHome\lib\site-packages\requests\cookies.pyt
2014-07-09 18:15:23 +08:00
add_headerFscCs||j|<dS(N(R(R
2014-07-10 23:57:08 +08:00
Rtvalue((sSe:\github\Wox.JSONRPC\Output\Debug\PythonHome\lib\site-packages\requests\cookies.pytadd_unredirected_headerJscCs|jS(N(R(R
((sSe:\github\Wox.JSONRPC\Output\Debug\PythonHome\lib\site-packages\requests\cookies.pytget_new_headersMscCs
2014-07-09 18:15:23 +08:00
|j<00>S(N(R(R
2014-07-10 23:57:08 +08:00
((sSe:\github\Wox.JSONRPC\Output\Debug\PythonHome\lib\site-packages\requests\cookies.pyt unverifiablePscCs
2014-07-09 18:15:23 +08:00
|j<00>S(N(R(R
2014-07-10 23:57:08 +08:00
((sSe:\github\Wox.JSONRPC\Output\Debug\PythonHome\lib\site-packages\requests\cookies.pytorigin_req_hostTscCs
2014-07-09 18:15:23 +08:00
|j<00>S(N(R(R
2014-07-10 23:57:08 +08:00
((sSe:\github\Wox.JSONRPC\Output\Debug\PythonHome\lib\site-packages\requests\cookies.pyRXsN(t__name__t
__module__t__doc__R R RRRRRtNoneR R$R&R'tpropertyR(R)R(((sSe:\github\Wox.JSONRPC\Output\Debug\PythonHome\lib\site-packages\requests\cookies.pyRs
2014-07-09 18:15:23 +08:00
           t MockResponsecBs)eZdZd<00>Zd<00>Zd<00>ZRS(s<>Wraps a `httplib.HTTPMessage` to mimic a `urllib.addinfourl`.
...what? Basically, expose the parsed HTTP headers from the server response
the way `cookielib` expects to see them.
cCs ||_dS(s<>Make a MockResponse for `cookielib` to read.
:param headers: a httplib.HTTPMessage or analogous carrying the headers
N(t_headers(R
2014-07-10 23:57:08 +08:00
R((sSe:\github\Wox.JSONRPC\Output\Debug\PythonHome\lib\site-packages\requests\cookies.pyR dscCs|jS(N(R0(R
((sSe:\github\Wox.JSONRPC\Output\Debug\PythonHome\lib\site-packages\requests\cookies.pytinfokscCs|jj|<00>dS(N(R0t
2014-07-09 18:15:23 +08:00
getheaders(R
2014-07-10 23:57:08 +08:00
R((sSe:\github\Wox.JSONRPC\Output\Debug\PythonHome\lib\site-packages\requests\cookies.pyR2ns(R*R+R,R R1R2(((sSe:\github\Wox.JSONRPC\Output\Debug\PythonHome\lib\site-packages\requests\cookies.pyR/]s  cCsNt|d<00>o|jsdSt|<00>}t|jj<00>}|j||<00>dS(s<>Extract the cookies from the response into a CookieJar.
2014-07-09 18:15:23 +08:00
:param jar: cookielib.CookieJar (not necessarily a RequestsCookieJar)
:param request: our own requests.Request object
:param response: urllib3.HTTPResponse object
2014-07-10 23:57:08 +08:00
t_original_responseN(thasattrR3RR/tmsgtextract_cookies(tjarR tresponsetreqtres((sSe:\github\Wox.JSONRPC\Output\Debug\PythonHome\lib\site-packages\requests\cookies.pytextract_cookies_to_jarrs   cCs,t|<00>}|j|<00>|j<00>jd<00>S(sOProduce an appropriate Cookie header string to be sent with `request`, or None.tCookie(Rtadd_cookie_headerR'R(R7R tr((sSe:\github\Wox.JSONRPC\Output\Debug\PythonHome\lib\site-packages\requests\cookies.pytget_cookie_header<65>s  cCs<>g}x{|D]s}|j|kr |dks=||jkr<>|dksX||jkr}|j|j|j|jf<00>q}q<>q q Wx*|D]"\}}}|j|||<00>q<>WdS(skUnsets a cookie by name, by default over all domains and paths.
2014-07-09 18:15:23 +08:00
Wraps CookieJar.clear(), is O(n).
N(RR-tdomainRtappendtclear(t cookiejarRR@Rt
2014-07-10 23:57:08 +08:00
clearablestcookie((sSe:\github\Wox.JSONRPC\Output\Debug\PythonHome\lib\site-packages\requests\cookies.pytremove_cookie_by_name<6D>s ,tCookieConflictErrorcBseZdZRS(s<>There are two cookies that meet the criteria specified in the cookie jar.
Use .get and .set and include domain and path args in order to be more specific.(R*R+R,(((sSe:\github\Wox.JSONRPC\Output\Debug\PythonHome\lib\site-packages\requests\cookies.pyRG<00>stRequestsCookieJarcBs<>eZdZdddd<00>Zd<00>Zd<00>Zd<00>Zd<00>Zd<00>Z d<00>Z
2014-07-09 18:15:23 +08:00
d<00>Z d <00>Z d
<00>Z d <00>Zddd <00>Zd <00>Zd<00>Zd<00>Zd<00>Zd<00>Zddd<00>Zddd<00>Zd<00>Zd<00>Zd<00>ZRS(s<>Compatibility class; is a cookielib.CookieJar, but exposes a dict interface.
This is the CookieJar we create by default for requests and sessions that
don't specify one, since some clients may expect response.cookies and
session.cookies to support dict operations.
Don't use the dict interface internally; it's just for compatibility with
with external client code. All `requests` code should work out of the box
with externally provided instances of CookieJar, e.g., LWPCookieJar and
FileCookieJar.
Caution: dictionary operations that are normally O(1) may be O(n).
Unlike a regular CookieJar, this class is pickleable.
cCs0y|j|||<00>SWntk
r+|SXdS(s<>Dict-like get() that also supports optional domain and path args in
order to resolve naming collisions from using one cookie jar over
multiple domains. Caution: operation is O(n), not O(1).N(t_find_no_duplicatestKeyError(R
2014-07-10 23:57:08 +08:00
RRR@R((sSe:\github\Wox.JSONRPC\Output\Debug\PythonHome\lib\site-packages\requests\cookies.pyR<00>s cKs||dkr;t||d|jd<00>d|jd<00><00>dSt|t<00>rYt|<00>}nt|||<00>}|j|<00>|S(s<>Dict-like set() that also supports optional domain and path args in
2014-07-09 18:15:23 +08:00
order to resolve naming collisions from using one cookie jar over
multiple domains.R@RN(R-RFRt
isinstanceRtmorsel_to_cookiet create_cookiet
set_cookie(R
2014-07-10 23:57:08 +08:00
RR%tkwargstc((sSe:\github\Wox.JSONRPC\Output\Debug\PythonHome\lib\site-packages\requests\cookies.pytset<65>s + ccs#xt|<00>D]}|jVq WdS(syDict-like iterkeys() that returns an iterator of names of cookies from the jar.
2014-07-09 18:15:23 +08:00
See itervalues() and iteritems().N(titerR(R
2014-07-10 23:57:08 +08:00
RE((sSe:\github\Wox.JSONRPC\Output\Debug\PythonHome\lib\site-packages\requests\cookies.pytiterkeys<79>scCst|j<00><00>S(shDict-like keys() that returns a list of names of cookies from the jar.
2014-07-09 18:15:23 +08:00
See values() and items().(tlistRS(R
2014-07-10 23:57:08 +08:00
((sSe:\github\Wox.JSONRPC\Output\Debug\PythonHome\lib\site-packages\requests\cookies.pytkeys<79>sccs#xt|<00>D]}|jVq WdS(szDict-like itervalues() that returns an iterator of values of cookies from the jar.
2014-07-09 18:15:23 +08:00
See iterkeys() and iteritems().N(RRR%(R
2014-07-10 23:57:08 +08:00
RE((sSe:\github\Wox.JSONRPC\Output\Debug\PythonHome\lib\site-packages\requests\cookies.pyt
2014-07-09 18:15:23 +08:00
itervalues<65>scCst|j<00><00>S(siDict-like values() that returns a list of values of cookies from the jar.
See keys() and items().(RTRV(R
2014-07-10 23:57:08 +08:00
((sSe:\github\Wox.JSONRPC\Output\Debug\PythonHome\lib\site-packages\requests\cookies.pytvalues<65>sccs,x%t|<00>D]}|j|jfVq WdS(szDict-like iteritems() that returns an iterator of name-value tuples from the jar.
2014-07-09 18:15:23 +08:00
See iterkeys() and itervalues().N(RRRR%(R
2014-07-10 23:57:08 +08:00
RE((sSe:\github\Wox.JSONRPC\Output\Debug\PythonHome\lib\site-packages\requests\cookies.pyt iteritems<6D>scCst|j<00><00>S(s<>Dict-like items() that returns a list of name-value tuples from the jar.
2014-07-09 18:15:23 +08:00
See keys() and values(). Allows client-code to call "dict(RequestsCookieJar)
and get a vanilla python dict of key value pairs.(RTRX(R
2014-07-10 23:57:08 +08:00
((sSe:\github\Wox.JSONRPC\Output\Debug\PythonHome\lib\site-packages\requests\cookies.pytitems<6D>scCsCg}x6t|<00>D](}|j|kr|j|j<00>qqW|S(s2Utility method to list all the domains in the jar.(RRR@RA(R
tdomainsRE((sSe:\github\Wox.JSONRPC\Output\Debug\PythonHome\lib\site-packages\requests\cookies.pyt list_domains<6E>s
2014-07-09 18:15:23 +08:00
cCsCg}x6t|<00>D](}|j|kr|j|j<00>qqW|S(s0Utility method to list all the paths in the jar.(RRRRA(R
2014-07-10 23:57:08 +08:00
tpathsRE((sSe:\github\Wox.JSONRPC\Output\Debug\PythonHome\lib\site-packages\requests\cookies.pyt
2014-07-09 18:15:23 +08:00
list_paths<68>s
2014-07-10 23:57:08 +08:00
cCsSg}xFt|<00>D]8}|jdk r;|j|kr;tS|j|j<00>qWtS(sWReturns True if there are multiple domains in the jar.
2014-07-09 18:15:23 +08:00
Returns False otherwise.N(RRR@R-RRAtFalse(R
2014-07-10 23:57:08 +08:00
RZRE((sSe:\github\Wox.JSONRPC\Output\Debug\PythonHome\lib\site-packages\requests\cookies.pytmultiple_domains<6E>s cCsji}x]t|<00>D]O}|dks4|j|kr|dksO|j|kr|j||j<qqW|S(s<>Takes as an argument an optional domain and path and returns a plain old
2014-07-09 18:15:23 +08:00
Python dict of name-value pairs of cookies that meet the requirements.N(RRR-R@RR%R(R
R@Rt
2014-07-10 23:57:08 +08:00
dictionaryRE((sSe:\github\Wox.JSONRPC\Output\Debug\PythonHome\lib\site-packages\requests\cookies.pytget_dicts 'cCs |j|<00>S(s<>Dict-like __getitem__() for compatibility with client code. Throws exception
2014-07-09 18:15:23 +08:00
if there are more than one cookie with name. In that case, use the more
explicit get() method instead. Caution: operation is O(n), not O(1).(RI(R
2014-07-10 23:57:08 +08:00
R((sSe:\github\Wox.JSONRPC\Output\Debug\PythonHome\lib\site-packages\requests\cookies.pyt __getitem__scCs|j||<00>dS(s<>Dict-like __setitem__ for compatibility with client code. Throws exception
2014-07-09 18:15:23 +08:00
if there is already a cookie of that name in the jar. In that case, use the more
explicit set() method instead.N(RQ(R
2014-07-10 23:57:08 +08:00
RR%((sSe:\github\Wox.JSONRPC\Output\Debug\PythonHome\lib\site-packages\requests\cookies.pyt __setitem__scCst||<00>dS(sSDeletes a cookie given a name. Wraps cookielib.CookieJar's remove_cookie_by_name().N(RF(R
R((sSe:\github\Wox.JSONRPC\Output\Debug\PythonHome\lib\site-packages\requests\cookies.pyt __delitem__scOsmt|jd<00>rQ|jjd<00>rQ|jjd<00>rQ|jjdd<00>|_ntt|<00>j|||<00>S(Nt
2014-07-09 18:15:23 +08:00
startswitht"s\"t(R4R%RetendswithtreplacetsuperRHRN(R
2014-07-10 23:57:08 +08:00
REtargsRO((sSe:\github\Wox.JSONRPC\Output\Debug\PythonHome\lib\site-packages\requests\cookies.pyRN!s6cCsMt|tj<00>r3x4|D]}|j|<00>qWntt|<00>j|<00>dS(sAUpdates this jar with cookies from another CookieJar or dict-likeN(RKRt CookieJarRNRjRHtupdate(R
totherRE((sSe:\github\Wox.JSONRPC\Output\Debug\PythonHome\lib\site-packages\requests\cookies.pyRm&s cCs<>xft|<00>D]X}|j|kr |dks=|j|kre|dksX|j|krb|jSqeq q Wtd|||f<16><00>dS(s6Requests uses this method internally to get cookie values. Takes as args name
2014-07-09 18:15:23 +08:00
and optional domain and path. Returns a cookie.value. If there are conflicting cookies,
_find arbitrarily chooses one. See _find_no_duplicates if you want an exception thrown
if there are conflicting cookies.sname=%r, domain=%r, path=%rN(RRRR-R@RR%RJ(R
2014-07-10 23:57:08 +08:00
RR@RRE((sSe:\github\Wox.JSONRPC\Output\Debug\PythonHome\lib\site-packages\requests\cookies.pyt_find.s cCs<>d}x<>t|<00>D]|}|j|kr|dksC|j|kr<>|dks^|j|kr<>|dk r}td|<16><00>n|j}q<>q<>qqW|r<>|Std|||f<16><00>dS(sA__get_item__ and get call _find_no_duplicates -- never used in Requests internally.
2014-07-09 18:15:23 +08:00
Takes as args name and optional domain and path. Returns a cookie.value.
Throws KeyError if cookie is not found and CookieConflictError if there are
multiple cookies that match name and optionally domain and path.s(There are multiple cookies with name, %rsname=%r, domain=%r, path=%rN(R-RRRR@RRGR%RJ(R
2014-07-10 23:57:08 +08:00
RR@RttoReturnRE((sSe:\github\Wox.JSONRPC\Output\Debug\PythonHome\lib\site-packages\requests\cookies.pyRI;s cCs |jj<00>}|jd<00>|S(s4Unlike a normal CookieJar, this class is pickleable.t _cookies_lock(t__dict__tcopytpop(R
tstate((sSe:\github\Wox.JSONRPC\Output\Debug\PythonHome\lib\site-packages\requests\cookies.pyt __getstate__Ms cCs5|jj|<00>d|jkr1tj<00>|_ndS(s4Unlike a normal CookieJar, this class is pickleable.RqN(RrRmt threadingtRLockRq(R
Ru((sSe:\github\Wox.JSONRPC\Output\Debug\PythonHome\lib\site-packages\requests\cookies.pyt __setstate__TscCst<00>}|j|<00>|S(s(Return a copy of this RequestsCookieJar.(RHRm(R
tnew_cj((sSe:\github\Wox.JSONRPC\Output\Debug\PythonHome\lib\site-packages\requests\cookies.pyRsZs  N(R*R+R,R-RRQRSRURVRWRXRYR[R]R_RaRbRcRdRNRmRoRIRvRyRs(((sSe:\github\Wox.JSONRPC\Output\Debug\PythonHome\lib\site-packages\requests\cookies.pyRH<00>s.         
2014-07-09 18:15:23 +08:00

       cKstddd|d|dddddd d
td dd td ddddidd6dt<00> }t|<00>t|<00>}|r<>d}t|t|<00><16><00>n|j|<00>t|d<19>|d<t|d<19>|d<|dj d<00>|d<t|d<19>|d<t
j |<00>S(s<>Make a cookie from underspecified parameters.
By default, the pair of `name` and `value` will be set for the domain ''
and sent on every request (this is sometimes called a "supercookie").
2014-07-10 23:57:08 +08:00
tversioniRR%tportR@RgRt/tsecuretexpirestdiscardtcommentt comment_urltresttHttpOnlytrfc2109s4create_cookie() got unexpected keyword arguments: %stport_specifiedtdomain_specifiedt.tdomain_initial_dottpath_specifiedN( tdictR-R^RRQt TypeErrorRTRmtboolReRR<(RR%ROtresulttbadargsterr((sSe:\github\Wox.JSONRPC\Output\Debug\PythonHome\lib\site-packages\requests\cookies.pyRMas0   cCs<>d}|dr'tj<00>|d}n9|dr`d}tjtj|d|<00><00>tj}ntd|ddt|d<19>dtd|dd|d|jd |d d
2014-07-09 18:15:23 +08:00
dd i|d d 6dtdt|d<19>d|j d|dp<>d<00> S(sBConvert a Morsel object into a Cookie containing the one k/v pair.smax-ageRs%a, %d-%b-%Y %H:%M:%S GMTR<54>R<>R<>R@RRR|R<>thttponlyR<79>R<>R~R%R{iN(
2014-07-10 23:57:08 +08:00
R-ttimetmktimetstrptimettimezoneRMR<>R^R"R%(tmorselRt time_template((sSe:\github\Wox.JSONRPC\Output\Debug\PythonHome\lib\site-packages\requests\cookies.pyRL<00>s*
2014-07-09 18:15:23 +08:00

#

 
2014-07-10 23:57:08 +08:00
 cCs<>|dkrt<00>}n|dk r<>g|D]}|j^q+}x@|D]5}|s_||krG|jt|||<19><00>qGqGWn|S(s-Returns a CookieJar from a key/value dictionary.
2014-07-09 18:15:23 +08:00
:param cookie_dict: Dict of key/values to insert into CookieJar.
:param cookiejar: (optional) A cookiejar to add the cookies to.
:param overwrite: (optional) If False, will not replace cookies
already in the jar with new ones.
2014-07-10 23:57:08 +08:00
N(R-RHRRNRM(t cookie_dictRCt overwriteREtnames_from_jarR((sSe:\github\Wox.JSONRPC\Output\Debug\PythonHome\lib\site-packages\requests\cookies.pytcookiejar_from_dict<63>s    $cCs<>t|tj<00>s!td<00><00>nt|t<00>rKt|d|dt<00>}nXt|tj<00>r<>y|j|<00>Wq<57>tk
2014-07-09 18:15:23 +08:00
r<>x|D]}|j |<00>q<>Wq<57>Xn|S(s<>Add cookies to cookiejar and returns a merged CookieJar.
:param cookiejar: CookieJar object to add the cookies to.
:param cookies: Dictionary or CookieJar object to be added.
s!You can only merge into CookieJarRCR<>(
RKRRlt
2014-07-10 23:57:08 +08:00
ValueErrorR<72>R<>R^RmtAttributeErrorRN(RCtcookiest cookie_in_jar((sSe:\github\Wox.JSONRPC\Output\Debug\PythonHome\lib\site-packages\requests\cookies.pyt merge_cookies<65>s  (R,R<>t collectionstcompatRRRRRwt ImportErrortdummy_threadingtobjectRR/R;R?R-RFt RuntimeErrorRGRltMutableMappingRHRMRLRR<>R<>(((sSe:\github\Wox.JSONRPC\Output\Debug\PythonHome\lib\site-packages\requests\cookies.pyt<module>s&  "  H  <1F> #