§
    sŠtjz  ã                   óª   — d Z ddlZddlmZ dZddddœZ ej        d	d
dg¦  «        Z G d„ d	e¦  «        Zd„ Z	d„ Z
d„ Zdd„Zd„ Zd„ Z	 	 dd„Zdd„ZdS )zGThis module provides functions for dumping information about responses.é    N)Úcompat)Údump_responseÚdump_alls   0.9s   1.0s   1.1)é	   é
   é   ÚPrefixSettingsÚrequestÚresponsec                   ó   ‡ — e Zd Zˆ fd„Zˆ xZS )r	   c                 ó”   •— t          |¦  «        }t          |¦  «        }t          t          | ¦  «                             | ||¦  «        S ©N)Ú_coerce_to_bytesÚsuperr	   Ú__new__)Úclsr
   r   Ú	__class__s      €úZ/var/www/html/CA-Chatbot/venv/lib/python3.11/site-packages/requests_toolbelt/utils/dump.pyr   zPrefixSettings.__new__   s?   ø€ Ý" 7Ñ+Ô+ˆÝ# HÑ-Ô-ˆÝ•^ SÑ)Ô)×1Ò1°#°wÀÑIÔIÐIó    )Ú__name__Ú
__module__Ú__qualname__r   Ú__classcell__)r   s   @r   r	   r	      sA   ø€ € € € € ðJð Jð Jð Jð Jð Jð Jð Jð Jr   c                 ó�   — t          | j        dd¦  «        r/i }| j        j        }|                     d¦  «        rd|d<   ||d<   |S d S )NÚproxy_managerFzhttps://ÚCONNECTÚmethodÚrequest_path)ÚgetattrÚ
connectionr
   ÚurlÚ
startswith)r   Ú
proxy_infoÚrequest_urls      r   Ú_get_proxy_informationr%      s^   € ÝˆxÔ" O°UÑ;Ô;ð Øˆ
ØÔ&Ô*ˆØ×!Ò! *Ñ-Ô-ð 	-Ø#,ˆJ�xÑ à%0ˆ
�>Ñ"ØÐØˆ4r   c                 óL   — t          | ¦  «        dz   t          |¦  «        z   dz   S )Ns   : ó   
)r   )ÚnameÚvalues     r   Ú_format_headerr*   &   s-   € Ý˜TÑ"Ô" UÑ*Õ-=¸eÑ-DÔ-DÑDØñð r   c                 óð   — t          j        | ¦  «        }|                     d¦  «        }|�t          |¦  «        }||fS t          |j        ¦  «        }|j        r|dt          |j        ¦  «        z   z  }||fS )Nr   ó   ?)r   ÚurlparseÚgetr   ÚpathÚquery)r!   r#   ÚuriÚ	proxy_urlr   s        r   Ú_build_request_pathr3   +   s~   € Ý
Œ/˜#Ñ
Ô
€CØ—’˜~Ñ.Ô.€IØÐÝ'¨	Ñ2Ô2ˆØ˜SÐ Ð å# C¤HÑ-Ô-€LØ
„yð ;Ø˜Õ/°´	Ñ:Ô:Ñ:Ñ:ˆà˜ÐÐr   c                 ól  — |€i }|j         }t          |                     d| j        ¦  «        ¦  «        }t	          | j        |¦  «        \  }}|                     ||z   dz   |z   dz   ¦  «         | j                             ¦   «         }t          |                     d|j	        ¦  «        ¦  «        }	|                     |dz   |	z   dz   ¦  «         | 
                    ¦   «         D ]+\  }
}|                     |t          |
|¦  «        z   ¦  «         Œ,|                     |dz   ¦  «         | j        rtt          | j        t          j        ¦  «        r+|                     |t          | j        ¦  «        z   ¦  «         n|                     d¦  «         |                     d¦  «         |                     d¦  «         d S )Nr   ó    s    HTTP/1.1
ÚHosts   Host: r'   s,   << Request body is not a string-like type >>)r
   r   Úpopr   r3   r!   ÚextendÚheadersÚcopyÚnetlocÚitemsr*   ÚbodyÚ
isinstancer   Ú
basestring)r
   ÚprefixesÚbytearrr#   Úprefixr   r   r1   r9   Úhost_headerr(   r)   s               r   Ú_dump_request_datarD   9   sŸ  € ØÐØˆ
àÔ€FÝ˜jŸnšn¨X°w´~ÑFÔFÑGÔG€FÝ+¨G¬K¸ÑDÔDÑ€L�#ð ‡N‚N�6˜F‘? TÑ)¨LÑ8Ð;KÑKÑLÔLÐLð Œo×"Ò"Ñ$Ô$€GÝ" 7§;¢;¨v°s´zÑ#BÔ#BÑCÔC€KØ‡N‚N�6˜IÑ%¨Ñ3°gÑ=Ñ>Ô>Ð>à—}’}‘”ð =ð =‰ˆˆeØ�Š�v¥¨t°UÑ ;Ô ;Ñ;Ñ<Ô<Ð<Ð<à‡N‚N�6˜GÑ#Ñ$Ô$Ð$Ø„|ð  Ý�g”l¥FÔ$5Ñ6Ô6ð 	LØ�NŠN˜6Õ$4°W´\Ñ$BÔ$BÑBÑCÔCÐCÐCð �NŠNÐJÑKÔKÐKØ�Š�wÑÔÐØ‡N‚N�7ÑÔÐÐÐr   c           	      ó@  — |j         }| j        }t                               |j        d¦  «        }|                     |dz   |z   dz   t          |j        ¦  «                             d¦  «        z   dz   t          | j
        ¦  «        z   dz   ¦  «         |j        }|                     ¦   «         D ]@}|                     |¦  «        D ](}|                     |t          ||¦  «        z   ¦  «         Œ)ŒA|                     |dz   ¦  «         |                     | j        ¦  «         d S )Nr,   s   HTTP/r5   Úasciir'   )r   ÚrawÚHTTP_VERSIONSr.   Úversionr8   ÚstrÚstatusÚencoder   Úreasonr9   ÚkeysÚgetlistr*   Úcontent)	r   r@   rA   rB   rG   Úversion_strr9   r(   r)   s	            r   Ú_dump_response_datarR   X   s3  € ØÔ€Fà
Œ,€Cõ  ×#Ò# C¤K°Ñ6Ô6€Kð ‡N‚N�6˜HÑ$ {Ñ2°TÑ9Ý�s”z‘?”?×)Ò)¨'Ñ2Ô2ñ3Ø59ñ:å# H¤OÑ4Ô4ñ5à7>ñ?ñ @ô @ð @ð Œk€GØ—’‘”ð Að AˆØ—_’_ TÑ*Ô*ð 	Að 	AˆEØ�NŠN˜6¥N°4¸Ñ$?Ô$?Ñ?Ñ@Ô@Ð@Ð@ð	Að ‡N‚N�6˜GÑ#Ñ$Ô$Ð$à‡N‚N�8Ô#Ñ$Ô$Ð$Ð$Ð$r   c                 ó‚   — t          | t          ¦  «        s%t          | d¦  «        r|                      d¦  «        } | �| ndS )NrL   zutf-8r   )r>   ÚbytesÚhasattrrL   )Údatas    r   r   r   o   sE   € Ý�d�EÑ"Ô"ð $¥w¨t°XÑ'>Ô'>ð $Ø�{Š{˜7Ñ#Ô#ˆàÐ#ˆ4ˆ4¨Ð,r   ó   < ó   > c                 óø   — |�|nt          ¦   «         }t          ||¦  «        }t          | d¦  «        st          d¦  «        ‚t	          | ¦  «        }t          | j        |||¬¦  «         t          | ||¦  «         |S )a  Dump a single request-response cycle's information.

    This will take a response object and dump only the data that requests can
    see for that single request-response cycle.

    Example::

        import requests
        from requests_toolbelt.utils import dump

        resp = requests.get('https://api.github.com/users/sigmavirus24')
        data = dump.dump_response(resp)
        print(data.decode('utf-8'))

    :param response:
        The response to format
    :type response: :class:`requests.Response`
    :param request_prefix: (*optional*)
        Bytes to prefix each line of the request data
    :type request_prefix: :class:`bytes`
    :param response_prefix: (*optional*)
        Bytes to prefix each line of the response data
    :type response_prefix: :class:`bytes`
    :param data_array: (*optional*)
        Bytearray to which we append the request-response cycle data
    :type data_array: :class:`bytearray`
    :returns: Formatted bytes of request and response information.
    :rtype: :class:`bytearray`
    Nr
   z"Response has no associated request)r#   )Ú	bytearrayr	   rU   Ú
ValueErrorr%   rD   r
   rR   )r   Úrequest_prefixÚresponse_prefixÚ
data_arrayrV   r@   r#   s          r   r   r   v   s�   € ð> $Ð/ˆ:ˆ:µY±[´[€DÝ˜n¨oÑ>Ô>€Hå�8˜YÑ'Ô'ð ?ÝÐ=Ñ>Ô>Ð>å'¨Ñ1Ô1€JÝ�xÔ'¨°4Ø",ð.ñ .ô .ð .å˜ (¨DÑ1Ô1Ð1Ø€Kr   c                 ó²   — t          ¦   «         }t          | j        dd…         ¦  «        }|                     | ¦  «         |D ]} t	          | |||¦  «         Œ|S )a›  Dump all requests and responses including redirects.

    This takes the response returned by requests and will dump all
    request-response pairs in the redirect history in order followed by the
    final request-response.

    Example::

        import requests
        from requests_toolbelt.utils import dump

        resp = requests.get('https://httpbin.org/redirect/5')
        data = dump.dump_all(resp)
        print(data.decode('utf-8'))

    :param response:
        The response to format
    :type response: :class:`requests.Response`
    :param request_prefix: (*optional*)
        Bytes to prefix each line of the request data
    :type request_prefix: :class:`bytes`
    :param response_prefix: (*optional*)
        Bytes to prefix each line of the response data
    :type response_prefix: :class:`bytes`
    :returns: Formatted bytes of request and response information.
    :rtype: :class:`bytearray`
    N)rZ   ÚlistÚhistoryÚappendr   )r   r\   r]   rV   ra   s        r   r   r   ¢   se   € õ8 ‰;Œ;€Då�8Ô# A A AÔ&Ñ'Ô'€GØ‡N‚N�8ÑÔÐàð Gð GˆÝ�h °ÀÑFÔFÐFÐFà€Kr   r   )rW   rX   N)rW   rX   )Ú__doc__ÚcollectionsÚrequestsr   Ú__all__rH   Ú
namedtupleÚ_PrefixSettingsr	   r%   r*   r3   rD   rR   r   r   r   © r   r   ú<module>rj      s8  ðØ MÐ MØ Ð Ð Ð à Ð Ð Ð Ð Ð ð (€ð ØØðð €ð )�+Ô(Ð)9Ø*3°ZÐ)@ñBô B€ðJð Jð Jð Jð J�_ñ Jô Jð Jð	ð 	ð 	ðð ð ð
ð ð ðð ð ð ð>%ð %ð %ð.-ð -ð -ð CHØ!ð)ð )ð )ð )ðX$ð $ð $ð $ð $ð $r   