
    'h              	          d dl Z d dlZd dlmZmZ d dlmZmZ d dlmZ d dl	m
Z
 e
j                  Ze
j                  Z G d dej                        Z	 	 dded	ed
ee
j&                     defdZdeeef   defdZd Zd Zy)    N)OptionalTuple)connectionsversionflow)httpc                   h    e Zd ZU dZeed<   dZee   ed<   dZ	ee
j                     ed<   	 ej                  ed<   ej                  ed<   dZeed	<   	 eed
<   	 d fd	Ze
j&                  j(                  j+                         Zej-                   eeee             d Zedefd       Z fdZ xZS )HTTPFlowz\
    An HTTPFlow is a collection of objects representing a single HTTP
    transaction.
    requestNresponseerrorserver_connclient_connFinterceptedmodec                 8    t         |   d|||       || _        y )Nr	   )super__init__r   )selfr   r   liver   	__class__s        f/var/www/html/scrapers/gsc/venv/lib/python3.12/site-packages/seleniumwire/thirdparty/mitmproxy/http.pyr   zHTTPFlow.__init__!   s    k4@	    )r   r   r   c                 v    d}dD ]  }t        | |d      s|d|d|dz  } |dz  }|j                  |       S )	Nz	<HTTPFlow)r   r   r   r   r   Fz
  z	 = {flow.}>r   )getattrformat)r   sas      r   __repr__zHTTPFlow.__repr__-   sM    O 	5AtQ&q!44	5 	
SxxTx""r   returnc                 .    | j                   j                  S N)r   timestamp_start)r   s    r   r&   zHTTPFlow.timestamp_start5   s    ||+++r   c                     t         |          }| j                  r| j                  j                         |_        | j                  r| j                  j                         |_        |S r%   )r   copyr   r   )r   fr   s     r   r(   zHTTPFlow.copy9   sI    GLN<<))+AI==++-AJr   )Nregular)__name__
__module____qualname____doc__HTTPRequest__annotations__r   r   HTTPResponser   r   Errorr   ServerConnectionClientConnectionr   boolstrr   Flow_stateobject_attributesr(   updatedictr"   propertyfloatr&   __classcell__)r   s   @r   r   r      s     '+Hh|$+"&E8DJJ&
 ------K5
IM #ii??DDF""4$ # , , , r   r   status_codemessageheadersr#   c           	         dj                         j                  | t        j                  j                  j                  | d      t        j                  |            j                  dd      }|s9t        j                  t        j                  dt        t        |            d      }t        j                  | ||      S )	Nz
        <html>
            <head>
                <title>{status_code} {reason}</title>
            </head>
            <body>
            <h1>{status_code} {reason}</h1>
            <p>{message}</p>
            </body>
        </html>
    Unknown)r>   reasonr?   utf8replaceclosez	text/html)Server
ConnectionContent_LengthContent_Type)stripr   r	   status_codes	RESPONSESgethtmlescapeencodeHeadersr   	MITMPROXYr6   lenr1   make)r>   r?   r@   bodys       r   make_error_responserW   B   s    

 	  **..{IFG$   fVY 	  ,,$$s4y>$	
 [$88r   addressc                     t        | d   | d   dd| d    d| d    j                         ddt        j                         dd t	        j                         t	        j                               S )Nr      s   CONNECTr   :s   HTTP/1.1)hostportmethodscheme	authoritypathhttp_versionr@   contenttrailersr&   timestamp_end)r/   rQ   r	   rR   time)rX   s    r   make_connect_requestrg   b   si    QZQZQZL'!*.557 		iik r   c                     t        | ddt        j                         dd t        j                         t        j                               S )N   s   Connection establishedr   )r1   r	   rR   rf   )rb   s    r   make_connect_responserj   s   s;     !					 	r   c                  ,    t         j                  d      S )Nd   )r1   rU    r   r   make_expect_continue_responsern      s    S!!r   ) N)rO   rf   typingr   r   !seleniumwire.thirdparty.mitmproxyr   r   r   %seleniumwire.thirdparty.mitmproxy.netr	   Requestr/   Responser1   r7   r   intr6   rR   rW   rg   rj   rn   rm   r   r   <module>rv      s      " B 2 6ll}}2tyy 2n *.999 $,,'9 	9@%S/ k ""r   