ó
    úÞ jz  ã                   ó¬   • S r SSKrSSKJr  SrSSSS.r\R                  " S	S
S/5      r " S S	\5      rS r	S r
S rSS jrS rS r  SS jrSS jrg)zGThis module provides functions for dumping information about responses.é    N)Úcompat)Údump_responseÚdump_alls   0.9s   1.0s   1.1)é	   é
   é   ÚPrefixSettingsÚrequestÚresponsec                   ó(   ^ • \ rS rSrU 4S jrSrU =r$ )r	   é   c                 óX   >• [        U5      n[        U5      n[        [        U ]  XU5      $ ©N)Ú_coerce_to_bytesÚsuperr	   Ú__new__)Úclsr
   r   Ú	__class__s      €ÚV/var/www/html/gaurav/venv/lib/python3.13/site-packages/requests_toolbelt/utils/dump.pyr   ÚPrefixSettings.__new__   s+   ø€ Ü" 7Ó+ˆÜ# HÓ-ˆÜ”^ SÑ1°#ÀÓIÐIó    © )Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__r   Ú__static_attributes__Ú__classcell__)r   s   @r   r	   r	      s   ø† ÷Jó Jr   c                 ó®   • [        U R                  SS5      (       a9  0 nU R                  R                  nUR	                  S5      (       a  SUS'   X!S'   U$ g )NÚproxy_managerFzhttps://ÚCONNECTÚmethodÚrequest_path)ÚgetattrÚ
connectionr
   ÚurlÚ
startswith)r   Ú
proxy_infoÚrequest_urls      r   Ú_get_proxy_informationr*      sY   € Üˆx×"Ñ" O°U×;Ñ;Øˆ
Ø×&Ñ&×*Ñ*ˆØ×!Ñ! *×-Ñ-Ø#,ˆJ�xÑ à%0�>Ñ"ØÐØr   c                 ó<   • [        U 5      S-   [        U5      -   S-   $ )Ns   : ó   
)r   )ÚnameÚvalues     r   Ú_format_headerr/   &   s'   € Ü˜TÓ" UÑ*Ô-=¸eÓ-DÑDØñð r   c                 óú   • [         R                  " U 5      nUR                  S5      nUb  [        U5      nXB4$ [        UR                  5      nUR
                  (       a  US[        UR
                  5      -   -  nXB4$ )Nr#   ó   ?)r   ÚurlparseÚgetr   ÚpathÚquery)r&   r(   ÚuriÚ	proxy_urlr#   s        r   Ú_build_request_pathr8   +   sn   € Ü
�/Š/˜#Ó
€CØ—‘˜~Ó.€IØÑÜ'¨	Ó2ˆØÐ Ð ä# C§H¡HÓ-€LØ
‡y‡yØ˜Ô/°·	±	Ó:Ñ:Ñ:ˆàÐÐr   c                 óH  • Uc  0 nUR                   n[        UR                  SU R                  5      5      n[	        U R
                  U5      u  pgUR                  XE-   S-   U-   S-   5        U R                  R                  5       n[        UR                  SUR                  5      5      n	UR                  US-   U	-   S-   5        UR                  5        H"  u  p«UR                  U[        X«5      -   5        M$     UR                  US-   5        U R                  (       as  [        U R                  [        R                  5      (       a(  UR                  U[        U R                  5      -   5        OUR                  S5        UR                  S5        UR                  S5        g )Nr"   ó    s    HTTP/1.1
ÚHosts   Host: r,   s,   << Request body is not a string-like type >>)r
   r   Úpopr"   r8   r&   ÚextendÚheadersÚcopyÚnetlocÚitemsr/   ÚbodyÚ
isinstancer   Ú
basestring)r
   ÚprefixesÚbytearrr(   Úprefixr"   r#   r6   r>   Úhost_headerr-   r.   s               r   Ú_dump_request_datarI   9   sG  € ØÑØˆ
à×Ñ€FÜ˜jŸn™n¨X°w·~±~ÓFÓG€FÜ+¨G¯K©K¸ÓDÑ€Lð ‡N�N�6‘? TÑ)¨LÑ8Ð;KÑKÔLð �o‰o×"Ñ"Ó$€GÜ" 7§;¡;¨v°s·z±zÓ#BÓC€KØ‡N�N�6˜IÑ%¨Ñ3°gÑ=Ô>à—}‘}–‰ˆØ�‰�v¤¨tÓ ;Ñ;Ö<ñ 'ð ‡N�N�6˜GÑ#Ô$Ø‡|‡|Ü�g—l‘l¤F×$5Ñ$5×6Ñ6Ø�N‰N˜6Ô$4°W·\±\Ó$BÑBÕCð �N‰NÐJÔKØ�‰�wÔØ‡N�N�7Õr   c           	      ó8  • UR                   nU R                  n[        R                  UR                  S5      nUR                  US-   U-   S-   [        UR                  5      R                  S5      -   S-   [        U R                  5      -   S-   5        UR                  nUR                  5        H8  nUR                  U5       H   nUR                  U[        Xx5      -   5        M"     M:     UR                  US-   5        UR                  U R                  5        g )Nr1   s   HTTP/r:   Úasciir,   )r   ÚrawÚHTTP_VERSIONSr3   Úversionr=   ÚstrÚstatusÚencoder   Úreasonr>   ÚkeysÚgetlistr/   Úcontent)	r   rE   rF   rG   rL   Úversion_strr>   r-   r.   s	            r   Ú_dump_response_datarW   X   só   € Ø×Ñ€Fà
�,‰,€Cô  ×#Ñ# C§K¡K°Ó6€Kð ‡N�N�6˜HÑ$ {Ñ2°TÑ9Ü�s—z‘z“?×)Ñ)¨'Ó2ñ3Ø59ñ:ä# H§O¡OÓ4ñ5à7>ñ?ô @ð �k‰k€GØ—‘–ˆØ—_‘_ TÖ*ˆEØ�N‰N˜6¤N°4Ó$?Ñ?Ö@ó +ñ ð ‡N�N�6˜GÑ#Ô$à‡N�N�8×#Ñ#Õ$r   c                 ó~   • [        U [        5      (       d"  [        U S5      (       a  U R                  S5      n U b  U $ S$ )NrQ   zutf-8r   )rC   ÚbytesÚhasattrrQ   )Údatas    r   r   r   o   s9   € Ü�dœE×"Ñ"¤w¨t°X×'>Ñ'>Ø�{‰{˜7Ó#ˆàÑ#ˆ4Ð,¨Ð,r   c                 óÊ   • Ub  UO	[        5       n[        X5      n[        U S5      (       d  [        S5      e[	        U 5      n[        U R                  XTUS9  [        XU5        U$ )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`
r
   z"Response has no associated request)r(   )Ú	bytearrayr	   rZ   Ú
ValueErrorr*   rI   r
   rW   )r   Úrequest_prefixÚresponse_prefixÚ
data_arrayr[   rE   r(   s          r   r   r   v   sc   € ð> $Ñ/‰:´Y³[€DÜ˜nÓ>€Hä�8˜Y×'Ñ'ÜÐ=Ó>Ð>ä'¨Ó1€JÜ�x×'Ñ'¨Ø",ò.ä˜¨DÔ1Ø€Kr   c                 ó–   • [        5       n[        U R                  SS 5      nUR                  U 5        U H  n [	        XX#5        M     U$ )aG  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)r]   ÚlistÚhistoryÚappendr   )r   r_   r`   r[   rd   s        r   r   r   ¢   sG   € ô8 ‹;€Dä�8×#Ñ#¡AÐ&Ó'€GØ‡N�N�8ÔãˆÜ�h°ÖFñ ð €Kr   r   )ó   < ó   > N)rf   rg   )Ú__doc__ÚcollectionsÚrequestsr   Ú__all__rM   Ú
namedtupleÚ_PrefixSettingsr	   r*   r/   r8   rI   rW   r   r   r   r   r   r   Ú<module>rn      s†   ðÙ MÛ å ð (€ð ØØñ€ð ×(Ò(Ð)9Ø*3°ZÐ)@óB€ôJ�_ô Jò	òò
ôò>%ò.-ð CHØ!ô)õX$r   