
    hg              	           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dS )    N)OptionalTuple)connectionsversionflow)httpc                   ^    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                                        Ze                     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moderegularc                 ^    t                                          d|||           || _        d S )Nr	   )super__init__r   )selfr   r   liver   	__class__s        _/var/www/fb-scrape/myenv/lib/python3.11/site-packages/seleniumwire/thirdparty/mitmproxy/http.pyr   zHTTPFlow.__init__!   s,    k4@@@			    )r   r   r   c                     d}dD ]}t          | |d          r|d|d|dz  } |dz  }|                    |           S )	Nz	<HTTPFlow)r   r   r   r   r   Fz
  z	 = {flow.}>r   )getattrformat)r   sas      r   __repr__zHTTPFlow.__repr__-   sa    O 	5 	5AtQ&& 5qqq!!!44	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        r| j                                        |_        |S r&   )r   copyr   r   )r   fr   s     r   r)   zHTTPFlow.copy9   sW    GGLLNN< 	,))++AI= 	.++--AJr   )Nr   )__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      sc          '+Hh|$+++"&E8DJ&&&
 --------K5
IIIM      #i?DDFF""44$ $ $   # # # , , , , X,        r   r    status_codemessageheadersr$   c           	         d                                                     | t          j        j                            | d          t          j        |                                        dd          }|s<t          j	        t          j        dt          t          |                    d          }t                              | ||          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@   rA   bodys       r   make_error_responserX   B   s    

 	 *..{IFFG$$    fVY 	   
,$s4yy>>$	
 
 
 [$888r   addressc                     t          | d         | d         dd| d          d| d                                          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_versionrA   contenttrailersr'   timestamp_end)r/   rR   r	   rS   time)rY   s    r   make_connect_requestrh   b   sy    QZQZQZ..'!*..5577 	ikk   r   c                     t          | ddt          j                    dd t          j                    t          j                              S )N   s   Connection establishedr   )r1   r	   rS   rg   )rc   s    r   make_connect_responserk   s   s@     !			 	 	r   c                  6    t                               d          S )Nd   )r1   rV    r   r   make_expect_continue_responsero      s    S!!!r   )r>   N)rP   rg   typingr   r   !seleniumwire.thirdparty.mitmproxyr   r   r   %seleniumwire.thirdparty.mitmproxy.netr	   Requestr/   Responser1   r7   r   intr6   rS   rX   rh   rk   ro   rn   r   r   <module>rv      sE     " " " " " " " " B B B B B B B B 2 2 2 2 2 2 6 6 6 6 6 6l}2 2 2 2 2ty 2 2 2n *.9 999 $,'9 	9 9 9 9@%S/ k    "  " " " " "r   