
    tf]|                        d Z ddlZddlZddlmZ ddlZddlZddlZddlm	Z	 ddl
mZmZmZmZmZmZ ddlmZ ddlmZ ddlmZ dd	lmZ dd
lmZmZ ddlmZ ddlmZ erddl
m Z   ejB                  e"      Z# G d de      Z$ G d de%      Z&ddddddddddddddd Z' G d! d"e%      Z(d#e)d$e*fd%Z+ G d& d'e%      Z,i d(d)d*d+d,d-d.d/d0d1d2d3d4d5d6d7d8d9d:d;d<d=d>d?d@dAdBdCdDdEdFdGdHdIi dJdKdLdMdNdOdPdQdRdSdTdUdVdWdXdYdZd[d\d]d^d_d`dadbdcdddedfdgdhdidjdki dldmdndodpdqdrdsdtdudvdwdxdydzd{d|d}d~ddddddddddddddddddddddddd	Z-y)zNetwork Manager module.    N)OrderedDict)SimpleNamespace)	AwaitableDictListOptionalUnionTYPE_CHECKING)unquote)EventEmitter)
CDPSession)NetworkError)FrameManagerFrame)
debugError)Multimap)Setc                       e Zd ZdZ edddd      Zdeded	d
f fdZde	e
e
f   d	d
fdZde	e
e
f   d	d
fdZd	e	e
e
f   fdZded	d
fdZde
d	d
fdZded	d
fdZd2dZde	d	d
fdZde
ded	d
fdZded	d
fdZde	dee
   d	d
fdZde	d	d
fdZ	 d3dd d!ed"e	d#ed$ed%e	d	d
fd&Zd'e
dee
   d(e
d)ed*e
d+e	d,ee
   d-ed    d	d
fd.Zded	d
fd/Zded	d
fd0Zded	d
fd1Z  xZ!S )4NetworkManagerzNetworkManager class.requestresponserequestfailedrequestfinished)RequestResponseRequestFailedRequestFinishedclientframeManagerreturnNc                     t                    | _        | _        t	                _        t	                _        t                _        d _	        d _
        t                _        d _        d _        t                _        t                _         j                  j%                  d fd        j                  j%                  d j&                          j                  j%                  d j(                          j                  j%                  d j*                          j                  j%                  d j,                          j                  j%                  d	 j.                         y)
zMake new NetworkManager.FNzNetwork.requestWillBeSentc                 l    j                   j                  j                  j                  |             S N)_client_loopcreate_task_onRequestWillBeSent)eventselfs    c/var/www/html/software/conda/envs/higlass/lib/python3.12/site-packages/pyppeteer/network_manager.py<lambda>z)NetworkManager.__init__.<locals>.<lambda>:   s*    $,,,,88))%0     zNetwork.requestInterceptedzNetwork.requestServedFromCachezNetwork.responseReceivedzNetwork.loadingFinishedzNetwork.loadingFailed)super__init__r$   _frameManagerdict_requestIdToRequest_requestIdToResponseWillBeSentr   _extraHTTPHeaders_offline_credentialsset_attemptedAuthentications_userRequestInterceptionEnabled#_protocolRequestInterceptionEnabledr   _requestHashToRequestIds_requestHashToInterceptionIdson_onRequestIntercepted_onRequestServedFromCache_onResponseReceived_onLoadingFinished_onLoadingFailed)r)   r   r   	__class__s   `  r*   r.   zNetworkManager.__init__(   s   )AE IM+8C#6:=@U&/4,380(0
%-5Z*'	
 	4d6P6PQ8$:X:XY2D4L4LM143J3JK/1F1FGr,   credentialsc                 N   K   || _         | j                          d{    y7 w)z"Provide credentials for http auth.N)r5   "_updateProtocolRequestInterception)r)   rC   s     r*   authenticatezNetworkManager.authenticateD   s      '55777   %#%extraHTTPHeadersc           	      N  K   t               | _        |j                         D ]M  \  }}t        |t              st        d| dt        |       d      || j                  |j                         <   O | j                  j                  dd| j                  i       d{    y7 w)zSet extra http headers.zExpected value of header "z" to be string, but z
 is found.zNetwork.setExtraHTTPHeadersheadersN)
r   r3   items
isinstancestr	TypeErrortypelowerr$   send)r)   rH   kvs       r*   setExtraHTTPHeadersz"NetworkManager.setExtraHTTPHeadersI   s      "-$**, 	2DAqa%0 47):/0 0 12D""1779-	2 ll =!*D,B,B CE 	E 	Es   BB%B#B%c                 ,    t        di | j                  S )zGet extra http headers. )r0   r3   r)   s    r*   rH   zNetworkManager.extraHTTPHeadersV   s    -d,,--r,   valuec                    K   | j                   |k(  ry|| _         | j                  j                  d| j                   dddd       d{    y7 w)z#Change offline mode enable/disable.Nz Network.emulateNetworkConditionsr   )offlinelatencydownloadThroughputuploadThroughput)r4   r$   rQ   r)   rX   s     r*   setOfflineModezNetworkManager.setOfflineModeZ   sQ     ==E!ll B}}"$ "	E
  	 	s   AAA	A	userAgentc                 \   K   | j                   j                  dd|i       d{    y7 w)zSet user agent.zNetwork.setUserAgentOverridera   N)r$   rQ   )r)   ra   s     r*   setUserAgentzNetworkManager.setUserAgentf   s-     ll >!,i 8: 	: 	:s   ",*,c                 N   K   || _         | j                          d{    y7 w)zEnable request interception.N)r8   rE   r_   s     r*   setRequestInterceptionz%NetworkManager.setRequestInterceptionk   s      /4,55777rG   c                 B  K   | j                   xs t        | j                        }|| j                  k(  ry || _        |rddigng }t	        j
                  | j                  j                  dd|i      | j                  j                  dd|i             d {    y 7 w)N
urlPattern*zNetwork.setCacheDisabledcacheDisabledzNetwork.setRequestInterceptionpatterns)r8   boolr5   r9   asynciogatherr$   rQ   )r)   enabledrj   s      r*   rE   z1NetworkManager._updateProtocolRequestInterceptionp   s     77 +))* 	d>>>3:0,3\3'(nnLL* '* LL0X&	
 		
 		
s   BBBBr(   c                   K   | j                   rt        |j                  di             }| j                  j	                  |      }|r/| j                  ||       | j                  j                  ||       y | j                  j                  ||j                  d             || j                  |j                  d      <   y | j                  |d        y w)Nr   	requestId)
r9   generateRequestHashgetr;   
firstValue
_onRequestdeleter:   r6   r2   )r)   r(   requestHashinterceptionIds       r*   r'   z#NetworkManager._onRequestWillBeSent   s     33-eii	2.FGK!??JJ;WN~62299+~V  --11+uyy?UVNS33EIIk4JKt$s   CCmethodmsgc                    K   	 | j                   j                  ||       d {    y 7 # t        $ r}t        t        |       Y d }~y d }~ww xY wwr#   )r$   rQ   	Exceptionr   logger)r)   rx   ry   es       r*   _sendzNetworkManager._send   sA     	",,##FC000 	"vq!!	"s6   A+ )+ A+ 	AA	A	AAc           
         |j                  d      rd}|d   | j                  v rd}n,| j                  r d}| j                  j                  |d          t	        | di       j                  d      }t	        | di       j                  d      }| j
                  j                  j                  | j                  d	|d   |||d
d             y | j                  sF| j                  r:| j
                  j                  j                  | j                  d	d|d   i             t        |d         }| j                  j                  |      }|ri| j                  |   }| j                  ||j                  d             | j                  j!                  ||       | j                  j#                  |d        y | j$                  j'                  ||d          y )NauthChallengeDefaultrw   
CancelAuthProvideCredentialsr5   usernamepassword"Network.continueInterceptedRequest)r   r   r   )rw   authChallengeResponser   )rr   r7   r5   addgetattrr$   r%   r&   r~   r8   r9   rq   r:   rs   r2   rt   ru   popr;   r6   )r)   r(   r   r   r   rv   rp   requestWillBeSentEvents           r*   r=   z$NetworkManager._onRequestIntercepted   s   99_% H%&$*H*HH'""/..2259I3JKt^R8<<ZHHt^R8<<ZHHLL**4::4&+,<&=$,$,$,.7	, 	 4488LL**4::4$e,<&=7,  *%	*:;11<<[I	%)%H%H%S"OO2EII>N4OP))00iH//33ItD..22;FV@WXr,   rw   c                    t               }|j                  d      r| j                  j                  |d         }|rr|d   }| j                  ||j                  d      |j                  d      |j                  d      |j                  d      |j                  d             |j                  }t        |j                  d      |j                  d      k(  xr |j                  d	      d
k(        }| j                  |d   ||j                  di       j                  d      ||j                  d	d      |j                  di       |j                  d      |       y )NredirectResponserp   statusrJ   fromDiskCachefromServiceWorkerSecurityDetailsloaderIdrO   Documentr   url frameId)listrr   r1   _handleRequestRedirect_redirectChainrk   _handleRequestStart)r)   r(   rw   redirectChainr   r   isNavigationRequests          r*   rt   zNetworkManager._onRequest   sC   '+v99'(..2253EFG#();#< ++$((2$((3$((9$(()<=$(():; !( 6 6"IIk"eii
&;; ,IIf+
 	  +IIi$((/IIfb!IIi$IIi 		
r,   c                 l    | j                   j                  |j                  d            }|rd|_        y y )Nrp   T)r1   rr   _fromMemoryCache)r)   r(   r   s      r*   r>   z(NetworkManager._onRequestServedFromCache   s1    **..uyy/EF'+G$ r,   r   redirectStatusredirectHeadersr   r   securityDetailsc           	         t        | j                  ||||||      }||_        |j                  j	                  |       |j                  t        d             | j                  j                  |j                  d        | j                  j                  |j                         | j                  t        j                  j                   |       | j                  t        j                  j                   |       y )Nz2Response body is unavailable for redirect response)r   r$   	_responser   append_bodyLoadedPromiseFulfillr   r1   r   
_requestIdr7   discard_interceptionIdemitr   Eventsr   )r)   r   r   r   r   r   r   r   s           r*   r   z%NetworkManager._handleRequestRedirect   s     DLL'>+]<M+- %%%g.**MN	
 	  $$W%7%7>&&..w/F/FG		.''00(;		.''77Ar,   rp   r   r   resourceTyperequestPayloadr   r   c	                    d }	|r'| j                   | j                   j                  |      }	t        | j                  |||| j                  ||||	|
      }
|
| j
                  |<   | j                  t        j                  j                  |
       y r#   )	r/   framer   r$   r8   r1   r   r   r   )r)   rp   rw   r   r   r   r   r   r   r   r   s              r*   r   z"NetworkManager._handleRequestStart   s     t))5&&,,W5E$,,	>->>&}N /6  +		.''//9r,   c                    | j                   j                  |d         }|sy |j                  di       }t        | j                  ||j                  dd      |j                  di       |j                  d      |j                  d      |j                  d            }||_        | j                  t        j                  j                  |       y )	Nrp   r   r   r   rJ   r   r   r   )r1   rr   r   r$   r   r   r   r   )r)   r(   r   _respr   s        r*   r?   z"NetworkManager._onResponseReceived  s    **..u[/AB		*b)DLL'!IIh2!IIi4!IIo6!II&9:!II&78: %		.''00(;r,   c                 n   | j                   j                  |d         }|sy |j                  }|r|j                  d        | j                   j	                  |j
                  d        | j                  j                  |j                         | j                  t        j                  j                  |       y )Nrp   )r1   rr   r   r   r   r   r7   r   r   r   r   r   r   r)   r(   r   r   s       r*   r@   z!NetworkManager._onLoadingFinished  s    **..u[/AB ##..t4  $$W%7%7>&&..w/F/FG		.''77Ar,   c                    | j                   j                  |d         }|sy |j                  d      |_        |j                  }|r|j	                  d        | j                   j                  |j                  d        | j                  j                  |j                         | j                  t        j                  j                  |       y )Nrp   	errorText)r1   rr   _failureTextr   r   r   r   r7   r   r   r   r   r   r   r   s       r*   rA   zNetworkManager._onLoadingFailed   s    **..u[/AB $yy5##..t4  $$W%7%7>&&..w/F/FG		.''55w?r,   )r    Nr#   )"__name__
__module____qualname____doc__r   r   r   r   r.   r   rM   rF   rT   rH   rk   r`   rc   re   rE   r'   r0   r~   r=   r   rt   r>   intr   r   r   r?   r@   rA   __classcell__)rB   s   @r*   r   r      s)   %)	FHz H H$ H88d38n 8 8
E$sCx. E'+E.$sCx. .
$ 
4 
:C :D :
8$ 84 8

$% % %"# "D "T "'Y4 'YD 'YR
 
hsm 
 
>,t , , 8<Bi B B04BEIB26B 15B AEB":S :,4SM:@C:15:EH: -1: <DC=: ,0	?	:
 "&:"< <$ <B B B@d @t @r,   r   c                   |   e Zd ZdZdedee   dee   dedededed	ed
ee	   de
d    ddfdZedefd       Zedefd       Zedee   fd       Zedee   fd       Zedefd       Zeded   fd       Zedee	   fd       ZdefdZede
d    fd       Zdee   fdZd deddfdZdeddfdZd!deddfdZy)"r   a  Request class.

    Whenever the page sends a request, such as for a network resource, the
    following events are emitted by pyppeteer's page:

    - ``'request'``: emitted when the request is issued by the page.
    - ``'response'``: emitted when/if the response is received for the request.
    - ``'requestfinished'``: emitted when the response body is downloaded and
      the request is complete.

    If request fails at some point, then instead of ``'requestfinished'`` event
    (and possibly instead of ``'response'`` event), the ``'requestfailed'``
    event is emitted.

    If request gets a ``'redirect'`` response, the request is successfully
    finished with the ``'requestfinished'`` event, and a new request is issued
    to a redirect url.
    r   rp   rw   r   allowInterceptionr   r   payloadr   r   r    Nc                    || _         || _        || _        || _        || _        d| _        d | _        d | _        || _        |j                         | _
        |j                  d      | _        |j                  d      | _        |j                  di       }|j                         D ci c]  \  }}|j                         | c}}| _        |	| _        |
| _        d| _        y c c}}w )NFrx   postDatarJ   )r$   r   _isNavigationRequestr   _allowInterception_interceptionHandledr   r   _urlrP   _resourceTyperr   _method	_postDatarK   _headers_framer   r   )r)   r   rp   rw   r   r   r   r   r   r   r   rJ   rR   rS   s                 r*   r.   zRequest.__init__C  s     #$7!-"3$)!-1+/	)//1{{8, Z0++i,29--/B$!QAB+ %	 Cs   &C c                     | j                   S )zURL of this request.r   rW   s    r*   r   zRequest.url]       yyr,   c                     | j                   S )a;  Resource type of this request perceived by the rendering engine.

        ResourceType will be one of the following: ``document``,
        ``stylesheet``, ``image``, ``media``, ``font``, ``script``,
        ``texttrack``, ``xhr``, ``fetch``, ``eventsource``, ``websocket``,
        ``manifest``, ``other``.
        )r   rW   s    r*   r   zRequest.resourceTypeb  s     !!!r,   c                     | j                   S )z/Return this request's method (GET, POST, etc.).)r   rW   s    r*   rx   zRequest.methodm       ||r,   c                     | j                   S )z!Return post body of this request.)r   rW   s    r*   r   zRequest.postDatar       ~~r,   c                     | j                   S )zgReturn a dictionary of HTTP headers of this request.

        All header names are lower-case.
        r   rW   s    r*   rJ   zRequest.headersw       }}r,   r   c                     | j                   S )zReturn matching :class:`Response` object, or ``None``.

        If the response has not been received, return ``None``.
        )r   rW   s    r*   r   zRequest.response  s     ~~r,   c                     | j                   S )zReturn a matching :class:`~pyppeteer.frame_manager.frame` object.

        Return ``None`` if navigating to error page.
        )r   rW   s    r*   r   zRequest.frame  s     {{r,   c                     | j                   S )z3Whether this request is driving frame's navigation.)r   rW   s    r*   r   zRequest.isNavigationRequest  s    (((r,   c                 @    t        j                   | j                        S )a  Return chain of requests initiated to fetch a resource.

        * If there are no redirects and request was successful, the chain will
          be empty.
        * If a server responds with at least a single redirect, then the chain
          will contain all the requests that were redirected.

        ``redirectChain`` is shared between all the requests of the same chain.
        )copyr   rW   s    r*   r   zRequest.redirectChain  s     yy,,--r,   c                 8    | j                   syd| j                   iS )a:  Return error text.

        Return ``None`` unless this request was failed, as reported by
        ``requestfailed`` event.

        When request failed, this method return dictionary which has a
        ``errorText`` field, which contains human-readable error message, e.g.
        ``'net::ERR_RAILED'``.
        Nr   )r   rW   s    r*   failurezRequest.failure  s!       T..//r,   	overridesc                 V  K   |i }| j                   st        d      | j                  rt        d      d| _        d| j                  i}|j	                  |       	 | j
                  j                  d|       d{    y7 # t        $ r}t        t        |       Y d}~yd}~ww xY ww)aY  Continue request with optional request overrides.

        To use this method, request interception should be enabled by
        :meth:`pyppeteer.page.Page.setRequestInterception`. If request
        interception is not enabled, raise ``NetworkError``.

        ``overrides`` can have the following fields:

        * ``url`` (str): If set, the request url will be changed.
        * ``method`` (str): If set, change the request method (e.g. ``GET``).
        * ``postData`` (str): If set, change the post data or request.
        * ``headers`` (dict): If set, change the request HTTP header.
        N$Request interception is not enabled.Request is already handled.Trw   r   )
r   r   r   r   updater$   rQ   r{   r   r|   )r)   r   optr}   s       r*   	continue_zRequest.continue_  s      I&&EFF$$<==$(!!5!56

9	",,##$H#NNN 	"vq!!	"sB   AB)B ;B<B  B)B 	B&B!B)!B&&B)r   c                   K   | j                   j                  d      ry| j                  st        d      | j                  rt        d      d| _        |j                  d      r(t        |d   t              r|d   j                  d      }n|j                  d      }i }|j                  d      r#|d   D ]  }|d   |   ||j                         <    |j                  d	      r|d	   |d
<   |rd|vrt        |      |d<   |j                  dd      }t        j                  |d      }d| d| }d}||z   }	|D ]  }|	 | d||    | }	 |	|z   }	|	j                  d      }
|r|
|z   }
t        j                  |
      j                  d      }	 | j                  j!                  d| j"                  |d       d{    y7 # t$        $ r}t'        t(        |       Y d}~yd}~ww xY ww)aV  Fulfills request with given response.

        To use this, request interception should by enabled by
        :meth:`pyppeteer.page.Page.setRequestInterception`. Request
        interception is not enabled, raise ``NetworkError``.

        ``response`` is a dictionary which can have the following fields:

        * ``status`` (int): Response status code, defaults to 200.
        * ``headers`` (dict): Optional response headers.
        * ``contentType`` (str): If set, equals to setting ``Content-Type``
          response header.
        * ``body`` (str|bytes): Optional response body.
        data:Nr   r   Tbodyutf-8rJ   contentTypezcontent-typezcontent-lengthr      r   z	HTTP/1.1  z
z: asciir   )rw   rawResponse)r   
startswithr   r   r   rr   rL   rM   encoderP   lenstatusTextsbase64	b64encodedecoder$   rQ   r   r{   r   r|   )r)   r   responseBodyresponseHeadersheader
statusCode
statusText
statusLineCRLFtextresponseBufferr   r}   s                r*   respondzRequest.respond  s     99(&&EFF$$<==$(!<<Jx/?$E,4V,<,C,CG,LL#<</L<<	""9- N2:92Ef2M/N<<&.6}.EON+,OC03L0AO,-\\(C0
 __Z4
 Aj\:
D % 	FFVF82of&=%>tfED	Fd{W-+l:N&&~6==gF	",,##$H"&"6"6*K     	"vq!!	"sB   FG),G ;G<G  G)G 	G&G!G)!G&&G)	errorCodec                   K   t         |   }|st        dj                  |            | j                  st        d      | j                  rt        d      d| _        	 | j
                  j                  dt        | j                  |             d{    y7 # t        $ r}t        t        |       Y d}~yd}~ww xY ww)ar  Abort request.

        To use this, request interception should be enabled by
        :meth:`pyppeteer.page.Page.setRequestInterception`.
        If request interception is not enabled, raise ``NetworkError``.

        ``errorCode`` is an optional error code string. Defaults to ``failed``,
        could be one of the following:

        - ``aborted``: An operation was aborted (due to user action).
        - ``accessdenied``: Permission to access a resource, other than the
          network, was denied.
        - ``addressunreachable``: The IP address is unreachable. This usually
          means that there is no route to the specified host or network.
        - ``blockedbyclient``: The client chose to block the request.
        - ``blockedbyresponse``: The request failed because the request was
          delivered along with requirements which are not met
          ('X-Frame-Options' and 'Content-Security-Policy' ancestor check,
          for instance).
        - ``connectionaborted``: A connection timeout as a result of not
          receiving an ACK for data sent.
        - ``connectionclosed``: A connection was closed (corresponding to a TCP
          FIN).
        - ``connectionfailed``: A connection attempt failed.
        - ``connectionrefused``: A connection attempt was refused.
        - ``connectionreset``: A connection was reset (corresponding to a TCP
          RST).
        - ``internetdisconnected``: The Internet connection has been lost.
        - ``namenotresolved``: The host name could not be resolved.
        - ``timedout``: An operation timed out.
        - ``failed``: A generic failure occurred.
        zUnknown error code: {}r   r   Tr   )rw   errorReasonN)errorReasonsr   formatr   r   r$   rQ   r0   r   r{   r   r|   )r)   r   r   r}   s       r*   abortzRequest.abort  s     B #9-7>>yIJJ&&EFF$$<==$(!	",,##$H$#33'K     	"vq!!	"sB   AC 4B BB C B 	B=#B83C 8B==C r#   )failed)r   r   r   r   r   r   rM   rk   r0   r   r   r.   propertyr   r   rx   r   r   rJ   r   r   r   r   r   r   r   r  rV   r,   r*   r   r   /  s   &&z &hsm &!)#&EI&$(&/2&BE& & (0& !%Y	&
 &4 S   "c " "    (3-      (:.   x  )T ) 
.tI 
. 
.0$ 0" " "<9"d 9"t 9"v/"S /" /"r,   r   AbortedAccessDeniedAddressUnreachableBlockedByClientBlockedByResponseConnectionAbortedConnectionClosedConnectionFailedConnectionRefusedConnectionResetInternetDisconnectedNameNotResolvedTimedOutFailed)abortedaccessdeniedaddressunreachableblockedbyclientblockedbyresponseconnectionabortedconnectionclosedconnectionfailedconnectionrefusedconnectionresetinternetdisconnectednamenotresolvedtimedoutr  c                   L   e Zd ZdZ	 ddedededeeef   de	de	d	ed
dfdZ
dee   d
dfdZed
efd       Zed
e	fd       Zed
efd       Zed
efd       Zed
eedf   fd       Zd
efdZd
ee   fdZd
efdZd
efdZed
efd       Zed
e	fd       Zed
e	fd       Zy)r   zCResponse class represents responses which are received by ``Page``.Nr   r   r   rJ   r   r   r   r    c                    || _         || _        || _        | j                   j                  j	                         | _        | j                   j                  j	                         | _        |j                  | _        || _	        || _
        |j                         D 	ci c]  \  }}	|j                         |	 c}	}| _        i | _        |r$t        |d   |d   |d   |d   |d         | _        y y c c}	}w )NsubjectNameissuer	validFromvalidToprotocol)r$   _request_statusr%   create_future_contentPromise_bodyLoadedPromiser   r   _fromDiskCache_fromServiceWorkerrK   rP   r   _securityDetailsr   )
r)   r   r   r   rJ   r   r   r   rR   rS   s
             r*   r.   zResponse.__init__N  s     #||11??A"&,,"4"4"B"B"DKK	+"329--/B$!QAB>@$3.),	*
+%D!  Cs   C,rX   c                 :    | j                   j                  |       y r#   )r+  
set_resultr_   s     r*   r   z"Response._bodyLoadedPromiseFulfillf  s    **51r,   c                     | j                   S )zURL of the response.r   rW   s    r*   r   zResponse.urli  r   r,   c                 X    | j                   dk(  xs d| j                   cxk  xr dk  S c S )z@Return bool whether this request is successful (200-299) or not.r   r   i+  r(  rW   s    r*   okzResponse.okn  s,     ||q >C4<<$>3$>>$>>r,   c                     | j                   S )zStatus code of the response.r3  rW   s    r*   r   zResponse.statuss  r   r,   c                     | j                   S )zfReturn dictionary of HTTP headers of this response.

        All header names are lower-case.
        r   rW   s    r*   rJ   zResponse.headersx  r   r,   r   c                     | j                   S )zReturn security details associated with this response.

        Security details if the response was received over the secure
        connection, or `None` otherwise.
        )r.  rW   s    r*   r   zResponse.securityDetails  s     $$$r,   c                 F  K   | j                    d {   }t        |t              r|| j                  j	                  dd| j
                  j                  i       d {   }|j                  dd      }|j                  d      rt        j                  |      S |S 7 7 @w)NzNetwork.getResponseBodyrp   r   r,   base64Encoded)
r+  rL   r{   r$   rQ   r'  r   rr   r   	b64decode)r)   resultr   r   s       r*   _bufreadzResponse._bufread  s     ...fi(L**+D11G
   ||FC(<<(##D)) /s"   B!BAB!B?B!B!c                     | j                   j                         s3| j                  j                  j	                  | j                               S | j                   S )z<Return awaitable which resolves to bytes with response body.)r*  doner$   r%   r&   r<  rW   s    r*   bufferzResponse.buffer  sA    ##((*<<%%11$--/BB###r,   c                    K   | j                          d{   }t        |t              r|S |j                  d      S 7 'w)z)Get text representation of response body.Nr   )r?  rL   rM   r   r)   contents     r*   r   zResponse.text  s7     %gs#N>>'**	 &s   A >(A c                 h   K   | j                          d{   }t        j                  |      S 7 w)z)Get JSON representation of response body.N)r   jsonloadsrA  s     r*   rD  zResponse.json  s(     		#zz'"" $s   202c                     | j                   S )z%Get matching :class:`Request` object.)r'  rW   s    r*   r   zResponse.request       }}r,   c                 J    | j                   xs | j                  j                  S )zReturn ``True`` if the response was served from cache.

        Here `cache` is either the browser's disk cache or memory cache.
        )r,  r'  r   rW   s    r*   	fromCachezResponse.fromCache  s     ""Ddmm&D&DDr,   c                     | j                   S )z?Return ``True`` if the response was served by a service worker.)r-  rW   s    r*   r   zResponse.fromServiceWorker  s     &&&r,   r#   )r   r   r   r   r   r   r   r   rM   rk   r.   r   r{   r   r  r   r4  r   rJ   r	   r   bytesr<  r   r?  r   r0   rD  r   rI  r   rV   r,   r*   r   r   K  s   M CGz G S sCx.9=$(;? 02x	/B 2t 2 S   ?D ? ?       %t->'>!? % %
 
$	%( $+C +#D #
    E4 E E '4 ' 'r,   r   r   r    c                    | j                  dd      }	 t        |      }|| j                  d      | j                  d      i d}|j                  d      sXt	        | d   j                               }|j                          |D ]'  }| d   |   }|j                         }|dv r ||d   |<   ) t        j                  |      S # t        $ r Y w xY w)	zGenerate request hash.r   r   rx   r   )r   rx   r   rJ   r   rJ   )acceptrefererz/x-devtools-emulate-network-conditions-client-idcookie)
rr   r   r{   r   r   keyssortrP   rD  dumps)r   normalizedURL_hashrJ   r   headerValues         r*   rq   rq     s    KKr*M.
 ++h'KK
+	E ##G,wy)..01 
	3F!),V4K\\^F   '2E)V$
	3 ::e1  s   C 	CCc                       e Zd ZdZdedededededdfd	Zedefd
       Zedefd       Z	edefd       Z
edefd       Zedefd       Zy)r   z6Class represents responses which are received by page.r"  r#  r$  r%  r&  r    Nc                 J    || _         || _        || _        || _        || _        y r#   )_subjectName_issuer
_validFrom_validTo	_protocol)r)   r"  r#  r$  r%  r&  s         r*   r.   zSecurityDetails.__init__  s&    '#!r,   c                     | j                   S )z:Return the subject to which the certificate was issued to.)rX  rW   s    r*   r"  zSecurityDetails.subjectName  s        r,   c                     | j                   S )z;Return a string with the name of issuer of the certificate.)rY  rW   s    r*   r#  zSecurityDetails.issuer  r   r,   c                     | j                   S )z<Return UnixTime of the start of validity of the certificate.)rZ  rW   s    r*   r$  zSecurityDetails.validFrom  s     r,   c                     | j                   S )z:Return UnixTime of the end of validity of the certificate.)r[  rW   s    r*   r%  zSecurityDetails.validTo  rG  r,   c                     | j                   S )z;Return string of with the security protocol, e.g. "TLS1.2".)r\  rW   s    r*   r&  zSecurityDetails.protocol  r   r,   )r   r   r   r   rM   r   r.   r  r"  r#  r$  r%  r&  rV   r,   r*   r   r     s    @"C " " ""),"15" !S ! !    3      #  r,   r   100Continue101zSwitching Protocols102
Processing200OK201Created202Accepted203zNon-Authoritative Information204z
No Content206zPartial Content207zMulti-Status208zAlready Reported209zIM Used300zMultiple Choices301zMoved Permanently302Found303z	See Other304zNot Modified305z	Use Proxy306zSwitch Proxy307zTemporary Redirect308zPermanent Redirect400zBad Request401Unauthorized402zPayment Required403	Forbidden404z	Not Found405zMethod Not Allowed406zNot Acceptable407zProxy Authentication Required408zRequest Timeout409Conflict410Gone411zLength Required412zPrecondition Failed413zPayload Too Large414zURI Too Long415zUnsupported Media Type416zRange Not Satisfiable417zExpectation Failed418zI'm a teapot421zMisdirected Request422zUnprocessable Entity423Locked424zFailed Dependency426zUpgrade Required428zPrecondition Required429zToo Many Requests431zRequest Header Fields Too Large451zUnavailable For Legal Reasons500zInternal Server Error501zNot ImplementedzBad GatewayzService UnavailablezGateway TimeoutzHTTP Version Not SupportedzVariant Also NegotiateszInsufficient StoragezLoop DetectedzNot ExtendedzNetwork Authentication Required)	502503504505506507508510511).r   rl   r   collectionsr   r   rD  loggingtypesr   typingr   r   r   r   r	   r
   urllib.parser   pyeer   pyppeteer.connectionr   pyppeteer.errorsr   pyppeteer.frame_managerr   r   pyppeteer.helperr   pyppeteer.multimapr   r   	getLoggerr   r|   r   objectr   r   r   r0   rM   rq   r   r   rV   r,   r*   <module>r     s      #    ! H H    + ) 7 ' '			8	$N@\ N@bG"f G"V ".(,,**,(2($m'v m'` # @"f "J=	:=	 = 
<= 
4	=
 
9= 
:= 
*= 
<= 
= 
>= 
= 
9= 
= 
= 
7=  
;!=" 
>#=$ 
;%=& 
>'=( 
)=* 
+=, 
=-=. 
>/=0 
1=2 
;3=4 
;5=6 
7=8 
9=: 
*;=< 
==> 
:?=@ 
6A=B 
C=D 
 E=F 
G=H 
>I=J 
#K=L 
"M=N 
O=P 
?Q=R 
 S=T 
!U=V 
8W=X 
Y=Z 
[=\ 
"]=^ 
_=` 
,a=b 
*c=d 
"e=f 
g=h  '$!,y=r,   