Warning: session_start(): Session cannot be started after headers have already been sent in /home/tvrreohg/public_html/manga.php on line 13
3 ÝPfpã @s¢dZddlZddlZddlZddlmZddlmZddlm Z ddl m Z m Z m Z mZmZddlmZmZmZmZdd lmZmZmZdd lmZmZdd lmZdd lmZm Z dd l!m"Z"m#Z#m$Z$m%Z%ddl&m'Z'ddl(m)Z)ddlm*Z*m+Z+m,Z,m-Z-m.Z.m/Z/m0Z0ddl1m2Z2ddlm3Z3ej4ƒdk�rXy ej5Z6Wne7k �rTej8Z6YnXnejZ6e fdd„Z9e fdd„Z:Gdd„de;ƒZdS)z“ requests.session ~~~~~~~~~~~~~~~~ This module provides a Session object to manage and persist settings across requests (cookies, auth, proxies). éN)ÚMapping)Ú timedeltaé)Ú_basic_auth_str)Ú cookielibÚis_py3Ú OrderedDictÚurljoinÚurlparse)Úcookiejar_from_dictÚextract_cookies_to_jarÚRequestsCookieJarÚ merge_cookies)ÚRequestÚPreparedRequestÚDEFAULT_REDIRECT_LIMIT)Ú default_hooksÚ dispatch_hook)Úto_native_string)Úto_key_val_listÚdefault_headers)ÚTooManyRedirectsÚ InvalidSchemaÚChunkedEncodingErrorÚContentDecodingError)ÚCaseInsensitiveDict)Ú HTTPAdapter)Ú requote_uriÚget_environ_proxiesÚget_netrc_authÚshould_bypass_proxiesÚget_auth_from_urlÚ rewind_bodyÚ DEFAULT_PORTS)Úcodes)ÚREDIRECT_STATIZWindowscCst|dkr |S|dkr|St|tƒo*t|tƒs0|S|t|ƒƒ}|jt|ƒƒdd„|jƒDƒ}x|D] }||=qbW|S)zèDetermines appropriate setting for a given request, taking into account the explicit setting on that request, and the setting in the session. If a setting is a dictionary, they will be merged together using `dict_class` NcSsg|]\}}|dkr|‘qS)N©)Ú.0ÚkÚvr&r&ú/usr/lib/python3.6/sessions.pyú Jsz!merge_setting..)Ú isinstancerrÚupdateÚitems)Zrequest_settingZsession_settingÚ dict_classZmerged_settingZ none_keysÚkeyr&r&r*Ú merge_setting2s     r1cCs@|dks|jdƒgkr|S|dks0|jdƒgkr4|St|||ƒS)z©Properly merges both requests and session hooks. This is necessary because when request_hooks == {'response': []}, the merge breaks Session hooks entirely. NÚresponse)Úgetr1)Z request_hooksZ session_hooksr/r&r&r*Ú merge_hooksQs r4c@s>eZdZdd„Zdd„Zddd „Zd d „Zd d „Zdd„ZdS)ÚSessionRedirectMixincCs,|jr(|jd}tr|jdƒ}t|dƒSdS)z7Receives a Response. Returns a redirect URI or ``None``ÚlocationÚlatin1Úutf8N)Z is_redirectÚheadersrÚencoder)ÚselfÚrespr6r&r&r*Úget_redirect_targetbs    z(SessionRedirectMixin.get_redirect_targetcCsœt|ƒ}t|ƒ}|j|jkr dS|jdkrL|jdkrL|jdkrL|jd krLdS|j|jk}|j|jk}tj|jdƒdf}| r”|j|kr”|j|kr”dS|pš|S) zFDecide whether Authorization header should be removed when redirectingTZhttpéPNZhttpsé»F)r>N)r?N)r ZhostnameÚschemeZportr#r3)r;Zold_urlZnew_urlZ old_parsedZ new_parsedZ changed_portZchanged_schemeZ default_portr&r&r*Úshould_strip_authxs    z&SessionRedirectMixin.should_strip_authFNTc ks.g} |j|ƒ} �x| �r(|jƒ} | j|ƒ| dd…|_y |jWn(tttfk rj|jj dd�YnXt |jƒ|j krŽt d|j |d�‚|j ƒ| jdƒr¼t|jƒ} dt| jƒ| f} t| ƒ}|jƒ} |jsät|jt| ƒƒ} nt| ƒ} t| ƒ| _|j| |ƒ|jtjtjfk�r>d}x|D]}| jj|dƒ�q Wd| _| j}y |d =Wntk �rdYnXt | j!||jƒt"| j!|j#ƒ| j$| j!ƒ|j%| |ƒ}|j&| |ƒ| j'dk �oÄd |k�pÄd |k}|�rÔt(| ƒ| }|�ræ|Vq|j)|f|||||dd œ| —Ž}t |j#| |jƒ|j|ƒ} |VqWdS)zBReceives a Response. Returns a generator of Responses or Requests.rNF)Zdecode_contentzExceeded %s redirects.)r2z//z%s:%súContent-Lengthú Content-TypeúTransfer-EncodingZCookie)ÚstreamÚtimeoutÚverifyÚcertÚproxiesÚallow_redirects)rBrCrD)*r=ÚcopyÚappendÚhistoryÚcontentrrÚ RuntimeErrorÚrawÚreadÚlenÚ max_redirectsrÚcloseÚ startswithr Úurlrr@ZgeturlZnetlocr rÚrebuild_methodÚ status_coder$Ztemporary_redirectZpermanent_redirectr9ÚpopZbodyÚKeyErrorr Z_cookiesrÚcookiesZprepare_cookiesÚrebuild_proxiesÚ rebuild_authZ_body_positionr"Úsend)r;r<ÚreqrErFrGrHrIÚyield_requestsZadapter_kwargsZhistrVÚprepared_requestZ parsed_rurlZparsedZpurged_headersÚheaderr9Z rewindabler&r&r*Úresolve_redirects‘sr               z&SessionRedirectMixin.resolve_redirectscCsR|j}|j}d|kr*|j|jj|ƒr*|d=|jr8t|ƒnd}|dk rN|j|ƒdS)zéWhen being redirected we may want to strip authentication from the request to avoid leaking credentials. This method intelligently removes and reapplies authentication where possible to avoid credential loss. Z AuthorizationN)r9rVrAÚrequestÚ trust_envrZ prepare_auth)r;rar2r9rVZnew_authr&r&r*r]ýs z!SessionRedirectMixin.rebuild_authc CsØ|dk r |ni}|j}|j}t|ƒj}|jƒ}|jdƒ}t||d�}|jr~| r~t||d�} | j|| jdƒƒ} | r~|j || ƒd|krŒ|d=yt ||ƒ\} } Wnt k r¼d\} } YnX| rÔ| rÔt | | ƒ|d<|S)a°This method re-evaluates the proxy configuration by considering the environment variables. If we are redirected to a URL covered by NO_PROXY, we strip the proxy configuration. Otherwise, we set missing proxy keys for this URL (in case they were stripped by a previous redirect). This method also replaces the Proxy-Authorization header where necessary. :rtype: dict NÚno_proxy)rfÚallzProxy-Authorization)NN) r9rVr r@rKr3r rerÚ setdefaultr!rZr) r;rarIr9rVr@Z new_proxiesrfZ bypass_proxyZenviron_proxiesÚproxyZusernameZpasswordr&r&r*r\s*       z$SessionRedirectMixin.rebuild_proxiescCsX|j}|jtjkr|dkrd}|jtjkr6|dkr6d}|jtjkrN|dkrNd}||_dS)z‚When being redirected we may want to change the method of the request based on certain specs or browser behavior. ÚHEADÚGETÚPOSTN)ÚmethodrXr$Z see_otherÚfoundZmoved)r;rar2rmr&r&r*rW:sz#SessionRedirectMixin.rebuild_method)FNTNNF) Ú__name__Ú __module__Ú __qualname__r=rArcr]r\rWr&r&r&r*r5`s k)r5c@sÎeZdZdZdddddddd d d d d dg Zdd„Zdd„Zdd„Zdd„Zd7dd„Z dd„Z dd„Z dd „Z d8d!d"„Z d9d#d$„Zd:d%d&„Zd'd(„Zd)d*„Zd+d,„Zd-d.„Zd/d0„Zd1d2„Zd3d4„Zd5d6„ZdS);ÚSessiona~A Requests session. Provides cookie persistence, connection-pooling, and configuration. Basic Usage:: >>> import requests >>> s = requests.Session() >>> s.get('http://httpbin.org/get') Or as a context manager:: >>> with requests.Session() as s: >>> s.get('http://httpbin.org/get') r9r[ÚauthrIÚhooksÚparamsrGrHZprefetchÚadaptersrErerScCsrtƒ|_d|_i|_tƒ|_i|_d|_d|_d|_ t |_ d|_ t iƒ|_tƒ|_|jdtƒƒ|jdtƒƒdS)NFTzhttps://zhttp://)rr9rsrIrrtrurErGrHrrSrer r[rrvÚmountr)r;r&r&r*Ú__init__js zSession.__init__cCs|S)Nr&)r;r&r&r*Ú __enter__¡szSession.__enter__cGs |jƒdS)N)rT)r;Úargsr&r&r*Ú__exit__¤szSession.__exit__c Cs¶|jpi}t|tjƒst|ƒ}tttƒ|jƒ|ƒ}|j}|jrV| rV|j rVt |j ƒ}t ƒ}|j |j jƒ|j |j|j|jt|j|jtd�t|j|jƒt||jƒ|t|j|jƒd� |S)a‹Constructs a :class:`PreparedRequest ` for transmission and returns it. The :class:`PreparedRequest` has settings merged from the :class:`Request ` instance and those of the :class:`Session`. :param request: :class:`Request` instance to prepare with this session's settings. :rtype: requests.PreparedRequest )r/) rmrVÚfilesÚdataÚjsonr9rursr[rt)r[r,rZ CookieJarr rr rsrerrVrZpreparermÚupperr|r}r~r1r9rrur4rt)r;rdr[Zmerged_cookiesrsÚpr&r&r*Úprepare_request§s*     zSession.prepare_requestNTc Cstt|jƒ||||pi||pi||| d� }|j|ƒ}| p8i} |j|j| | ||ƒ}| | dœ}|j|ƒ|j|f|Ž}|S)añConstructs a :class:`Request `, prepares it and sends it. Returns :class:`Response ` object. :param method: method for the new :class:`Request` object. :param url: URL for the new :class:`Request` object. :param params: (optional) Dictionary or bytes to be sent in the query string for the :class:`Request`. :param data: (optional) Dictionary, bytes, or file-like object to send in the body of the :class:`Request`. :param json: (optional) json to send in the body of the :class:`Request`. :param headers: (optional) Dictionary of HTTP Headers to send with the :class:`Request`. :param cookies: (optional) Dict or CookieJar object to send with the :class:`Request`. :param files: (optional) Dictionary of ``'filename': file-like-objects`` for multipart encoding upload. :param auth: (optional) Auth tuple or callable to enable Basic/Digest/Custom HTTP Auth. :param timeout: (optional) How long to wait for the server to send data before giving up, as a float, or a :ref:`(connect timeout, read timeout) ` tuple. :type timeout: float or tuple :param allow_redirects: (optional) Set to True by default. :type allow_redirects: bool :param proxies: (optional) Dictionary mapping protocol or protocol and hostname to the URL of the proxy. :param stream: (optional) whether to immediately download the response content. Defaults to ``False``. :param verify: (optional) Either a boolean, in which case it controls whether we verify the server's TLS certificate, or a string, in which case it must be a path to a CA bundle to use. Defaults to ``True``. :param cert: (optional) if String, path to ssl client cert file (.pem). If Tuple, ('cert', 'key') pair. :rtype: requests.Response ) rmrVr9r|r}r~rursr[rt)rFrJ)rrr�Úmerge_environment_settingsrVr-r^)r;rmrVrur}r9r[r|rsrFrJrIrtrErGrHr~r_ZprepZsettingsZ send_kwargsr<r&r&r*rdÏs()  zSession.requestcKs|jddƒ|jd|f|ŽS)zåSends a GET request. Returns :class:`Response` object. :param url: URL for the new :class:`Request` object. :param \*\*kwargs: Optional arguments that ``request`` takes. :rtype: requests.Response rJTrk)rhrd)r;rVÚkwargsr&r&r*r3s z Session.getcKs|jddƒ|jd|f|ŽS)zéSends a OPTIONS request. Returns :class:`Response` object. :param url: URL for the new :class:`Request` object. :param \*\*kwargs: Optional arguments that ``request`` takes. :rtype: requests.Response rJTZOPTIONS)rhrd)r;rVrƒr&r&r*Úoptions!s zSession.optionscKs|jddƒ|jd|f|ŽS)zæSends a HEAD request. Returns :class:`Response` object. :param url: URL for the new :class:`Request` object. :param \*\*kwargs: Optional arguments that ``request`` takes. :rtype: requests.Response rJFrj)rhrd)r;rVrƒr&r&r*Úhead,s z Session.headcKs|jd|f||dœ|—ŽS)a¬Sends a POST request. Returns :class:`Response` object. :param url: URL for the new :class:`Request` object. :param data: (optional) Dictionary, bytes, or file-like object to send in the body of the :class:`Request`. :param json: (optional) json to send in the body of the :class:`Request`. :param \*\*kwargs: Optional arguments that ``request`` takes. :rtype: requests.Response rl)r}r~)rd)r;rVr}r~rƒr&r&r*Úpost7s z Session.postcKs|jd|fd|i|—ŽS)aYSends a PUT request. Returns :class:`Response` object. :param url: URL for the new :class:`Request` object. :param data: (optional) Dictionary, bytes, or file-like object to send in the body of the :class:`Request`. :param \*\*kwargs: Optional arguments that ``request`` takes. :rtype: requests.Response ZPUTr})rd)r;rVr}rƒr&r&r*ÚputCs z Session.putcKs|jd|fd|i|—ŽS)a[Sends a PATCH request. Returns :class:`Response` object. :param url: URL for the new :class:`Request` object. :param data: (optional) Dictionary, bytes, or file-like object to send in the body of the :class:`Request`. :param \*\*kwargs: Optional arguments that ``request`` takes. :rtype: requests.Response ZPATCHr})rd)r;rVr}rƒr&r&r*ÚpatchNs z Session.patchcKs|jd|f|ŽS)zèSends a DELETE request. Returns :class:`Response` object. :param url: URL for the new :class:`Request` object. :param \*\*kwargs: Optional arguments that ``request`` takes. :rtype: requests.Response ZDELETE)rd)r;rVrƒr&r&r*ÚdeleteYszSession.deletec Ks~|jd|jƒ|jd|jƒ|jd|jƒ|jd|jƒt|tƒrJtdƒ‚|jddƒ}|j dƒ}|j }|j |j d�}t ƒ}|j|f|Ž}t ƒ|} t| d �|_td ||f|Ž}|jrÖx |jD]} t|j| j| jƒq¼Wt|j||jƒ|j||f|Ž} |�r d d „| Dƒng} | �r.| jd |ƒ| jƒ}| |_|�sny"t|j||fddi|—Žƒ|_Wntk �rlYnX|�sz|j|S)zISend a given PreparedRequest. :rtype: requests.Response rErGrHrIz#You can only send PreparedRequests.rJT)rV)Zsecondsr2cSsg|]}|‘qSr&r&)r'r<r&r&r*r+–sz Session.send..rr`)rhrErGrHrIr,rÚ ValueErrorrYr3rtÚ get_adapterrVÚpreferred_clockr^rÚelapsedrrMr r[rdrPrcÚinsertÚnextZ_nextÚ StopIterationrN) r;rdrƒrJrErtÚadapterÚstartÚrr�r<ÚgenrMr&r&r*r^csB       "z Session.sendc Cs°|jrr|dk r|jdƒnd}t||d�}x |jƒD]\}} |j|| ƒq2W|dksZ|dkrrtjjdƒpptjjdƒ}t||jƒ}t||j ƒ}t||j ƒ}t||j ƒ}||||dœS)z^ Check the environment and merge it with some settings. :rtype: dict Nrf)rfTZREQUESTS_CA_BUNDLEZCURL_CA_BUNDLE)rGrIrErH) rer3rr.rhÚosÚenvironr1rIrErGrH) r;rVrIrErGrHrfZ env_proxiesr(r)r&r&r*r‚¬s       z"Session.merge_environment_settingscCs:x(|jjƒD]\}}|jƒj|ƒr |Sq Wtd|ƒ‚dS)z~ Returns the appropriate connection adapter for the given URL. :rtype: requests.adapters.BaseAdapter z*No connection adapters were found for '%s'N)rvr.ÚlowerrUr)r;rVÚprefixr‘r&r&r*r‹ÉszSession.get_adaptercCs x|jjƒD] }|jƒq WdS)z+Closes all adapters and as such the sessionN)rvÚvaluesrT)r;r)r&r&r*rT×sz Session.closecsB||jˆ<‡fdd„|jDƒ}x|D]}|jj|ƒ|j|<q$WdS)zwRegisters a connection adapter to a prefix. Adapters are sorted in descending order by prefix length. cs g|]}t|ƒtˆƒkr|‘qSr&)rR)r'r()r˜r&r*r+âsz!Session.mount..N)rvrY)r;r˜r‘Z keys_to_mover0r&)r˜r*rwÜs  z Session.mountcst‡fdd„ˆjDƒƒ}|S)Nc3s|]}|tˆ|dƒfVqdS)N)Úgetattr)r'Úattr)r;r&r*ú èsz'Session.__getstate__..)ÚdictÚ __attrs__)r;Ústater&)r;r*Ú __getstate__çszSession.__getstate__cCs&x |jƒD]\}}t|||ƒq WdS)N)r.Úsetattr)r;rŸr›Úvaluer&r&r*Ú __setstate__ëszSession.__setstate__)NNNNNNNTNNNNNN)NN)N)N)rorprqÚ__doc__ržrxryr{r�rdr3r„r…r†r‡rˆr‰r^r‚r‹rTrwr r£r&r&r&r*rrQs2 7) D    I rrcCstƒS)zQ Returns a :class:`Session` for context-management. :rtype: Session )rrr&r&r&r*Úsessionðsr¥)?r¤r•ÚplatformZtimeÚ collectionsrZdatetimerrsrÚcompatrrrr r r[r r r rZmodelsrrrrtrrZ_internal_utilsrZutilsrrÚ exceptionsrrrrZ structuresrrvrrrrr r!r"r#Z status_codesr$r%ÚsystemZ perf_counterrŒÚAttributeErrorZclockr1r4Úobjectr5rrr¥r&r&r&r*Ú sB      $     r"