Ë
    ±Œjz  ã                   ó¦   — 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y)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                 óZ   •— t        |«      }t        |«      }t        t        | �  | ||«      S ©N)Ú_coerce_to_bytesÚsuperr	   Ú__new__)Úclsr
   r   Ú	__class__s      €úf/var/www/html/Fitness-lenito-AI-main/venv/lib/python3.12/site-packages/requests_toolbelt/utils/dump.pyr   zPrefixSettings.__new__   s-   ø€ Ü" 7Ó+ˆÜ# HÓ-ˆÜ”^ SÑ1°#°wÀÓIÐIó    )Ú__name__Ú
__module__Ú__qualname__r   Ú__classcell__)r   s   @r   r	   r	      s   ø„ ÷Jð Jr   c                 óœ   — t        | j                  dd«      r5i }| j                  j                  }|j	                  d«      rd|d<   ||d<   |S y )NÚproxy_managerFzhttps://ÚCONNECTÚmethodÚrequest_path)ÚgetattrÚ
connectionr
   ÚurlÚ
startswith)r   Ú
proxy_infoÚrequest_urls      r   Ú_get_proxy_informationr%      sU   € Üˆx×"Ñ" O°UÔ;Øˆ
Ø×&Ñ&×*Ñ*ˆØ×!Ñ! *Ô-Ø#,ˆJ�xÑ à%0ˆ
�>Ñ"ØÐØr   c                 ó<   — t        | «      dz   t        |«      z   dz   S )Ns   : ó   
)r   )ÚnameÚvalues     r   Ú_format_headerr*   &   s'   € Ü˜TÓ" UÑ*Ô-=¸eÓ-DÑDØñð r   c                 óð   — t        j                  | «      }|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   +   sr   € Ü
�/‰/˜#Ó
€CØ—‘˜~Ó.€IØÐÜ'¨	Ó2ˆØ˜SÐ Ð ä# C§H¡HÓ-€LØ
‡y‚yØ˜Ô/°·	±	Ó:Ñ:Ñ:ˆà˜ÐÐr   c                 ó6  — |€i }|j                   }t        |j                  d| j                  «      «      }t	        | j
                  |«      \  }}|j                  ||z   dz   |z   dz   «       | j                  j                  «       }t        |j                  d|j                  «      «      }	|j                  |dz   |	z   dz   «       |j                  «       D ]#  \  }
}|j                  |t        |
|«      z   «       Œ% |j                  |dz   «       | j                  rnt        | j                  t        j                  «      r(|j                  |t        | j                  «      z   «       n|j                  d«       |j                  d«       |j                  d«       y )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   sL  € ØÐØˆ
à×Ñ€FÜ˜jŸn™n¨X°w·~±~ÓFÓG€FÜ+¨G¯K©K¸ÓDÑ€L�#ð ‡N�N�6˜F‘? TÑ)¨LÑ8Ð;KÑKÔLð �o‰o×"Ñ"Ó$€GÜ" 7§;¡;¨v°s·z±zÓ#BÓC€KØ‡N�N�6˜IÑ%¨Ñ3°gÑ=Ô>à—}‘}–‰ˆˆeØ�‰�v¤¨t°UÓ ;Ñ;Õ<ð 'ð ‡N�N�6˜GÑ#Ô$Ø‡|‚|Ü�g—l‘l¤F×$5Ñ$5Ô6Ø�N‰N˜6Ô$4°W·\±\Ó$BÑBÕCð �N‰NÐJÔKØ�‰�wÔØ‡N�N�7Õr   c           	      ó2  — |j                   }| j                  }t        j                  |j                  d«      }|j                  |dz   |z   dz   t        |j                  «      j                  d«      z   dz   t        | j                  «      z   dz   «       |j                  }|j                  «       D ]6  }|j                  |«      D ]   }|j                  |t        ||«      z   «       Œ" Œ8 |j                  |dz   «       |j                  | j                  «       y )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   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                 óh   — t        | t        «      st        | d«      r| j                  d«      } | �| S dS )NrL   zutf-8r   )r>   ÚbytesÚhasattrrL   )Údatas    r   r   r   o   s3   € Ü�dœEÔ"¤w¨t°XÔ'>Ø�{‰{˜7Ó#ˆàÐ#ˆ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`
    r
   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   sf   € ð> $Ð/‰:´Y³[€DÜ˜n¨oÓ>€Hä�8˜YÔ'ÜÐ=Ó>Ð>ä'¨Ó1€JÜ�x×'Ñ'¨°4Ø",õ.ä˜ (¨DÔ1Ø€Kr   c                 ó–   — t        «       }t        | j                  dd «      }|j                  | «       |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)rX   ÚlistÚhistoryÚappendr   )r   rZ   r[   rV   r_   s        r   r   r   ¢   sK   € ô8 ‹;€Dä�8×#Ñ#¡AÐ&Ó'€GØ‡N�N�8ÔãˆÜ�h °ÀÕFð ð €Kr   r   )ó   < ó   > N)ra   rb   )Ú__doc__ÚcollectionsÚrequestsr   Ú__all__rH   Ú
namedtupleÚ_PrefixSettingsr	   r%   r*   r3   rD   rR   r   r   r   © r   r   Ú<module>rj      sˆ   ðÙ MÛ å ð (€ð ØØñ€ð )�+×(Ñ(Ð)9Ø*3°ZÐ)@óB€ôJ�_ô Jò	òò
óò>%ò.-ð CHØ!ó)ôX$r   