Ë
    ùmxiÃ'  ã                   óÜ   — d Z ddlmZ ddlZddlZddlmZ ddlmZ ddl	Z	 ej                  e«      ZdZ G d„ dej                  «      Z G d	„ d
ej                   «      Zd„ Z G d„ de«      Zy)zTransport adapter for httplib2.é    )Úabsolute_importN)Ú
exceptions)Ú	transport)ÚreadÚseekÚtellc                   óF   — e Zd ZdZd„ Zed„ «       Zed„ «       Zed„ «       Zy)Ú	_Responsezžhttplib2 transport response adapter.

    Args:
        response (httplib2.Response): The raw httplib2 response.
        data (bytes): The response body.
    c                 ó    — || _         || _        y ©N)Ú	_responseÚ_data)ÚselfÚresponseÚdatas      úK/home/htdocs/ttos/venv/lib/python3.12/site-packages/google_auth_httplib2.pyÚ__init__z_Response.__init__(   s   € Ø!ˆŒØˆ�
ó    c                 ó.   — | j                   j                  S )zint: The HTTP status code.)r   Ústatus©r   s    r   r   z_Response.status,   s   € ð �~‰~×$Ñ$Ð$r   c                 ó,   — t        | j                  «      S )z-Mapping[str, str]: The HTTP response headers.)Údictr   r   s    r   Úheadersz_Response.headers1   s   € ô �D—N‘NÓ#Ð#r   c                 ó   — | j                   S )zbytes: The response body.)r   r   s    r   r   z_Response.data6   s   € ð �z‰zÐr   N)	Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   Úpropertyr   r   r   © r   r   r
   r
       sH   „ ñòð ñ%ó ð%ð ñ$ó ð$ð ñó ñr   r
   c                   ó    — e Zd ZdZd„ Z	 dd„Zy)ÚRequesta…  httplib2 request adapter.

    This class is used internally for making requests using various transports
    in a consistent way. If you use :class:`AuthorizedHttp` you do not need
    to construct or use this class directly.

    This class can be useful if you want to manually refresh a
    :class:`~google.auth.credentials.Credentials` instance::

        import google_auth_httplib2
        import httplib2

        http = httplib2.Http()
        request = google_auth_httplib2.Request(http)

        credentials.refresh(request)

    Args:
        http (httplib2.Http): The underlying http object to use to make
            requests.
    c                 ó   — || _         y r   )Úhttp)r   r%   s     r   r   zRequest.__init__S   s	   € Øˆ�	r   Nc                 óT  — |�t         j                  d«       	 t         j                  d||«        | j                  j                  |f|||dœ|¤Ž\  }}t        ||«      S # t        j                  t        j                  j                  f$ r}	t        j                  |	«      ‚d}	~	ww xY w)a3  Make an HTTP request using httplib2.

        Args:
            url (str): The URI to be requested.
            method (str): The HTTP method to use for the request. Defaults
                to 'GET'.
            body (bytes): The payload / body in HTTP request.
            headers (Mapping[str, str]): Request headers.
            timeout (Optional[int]): The number of seconds to wait for a
                response from the server. This is ignored by httplib2 and will
                issue a warning.
            kwargs: Additional arguments passed throught to the underlying
                :meth:`httplib2.Http.request` method.

        Returns:
            google.auth.transport.Response: The HTTP response.

        Raises:
            google.auth.exceptions.TransportError: If any exception occurred.
        Nzvhttplib2 transport does not support per-request timeout. Set the timeout when constructing the httplib2.Http instance.zMaking request: %s %s)ÚmethodÚbodyr   )Ú_LOGGERÚwarningÚdebugr%   Úrequestr
   Úhttplib2ÚHttpLib2ErrorÚclientÚHTTPExceptionr   ÚTransportError)
r   Úurlr'   r(   r   ÚtimeoutÚkwargsr   r   Úexcs
             r   Ú__call__zRequest.__call__V   sª   € ð. ÐÜ�O‰OðPôð
		1Ü�M‰MÐ1°6¸3Ô?Ø.˜TŸY™Y×.Ñ.ØðØ"¨°wñØBHñ‰NˆH�dô ˜X tÓ,Ð,øô ×&Ñ&¬¯©×(AÑ(AÐBò 	1Ü×+Ñ+¨CÓ0Ð0ûð	1ús   ™AA  Á -B'ÂB"Â"B')ÚGETNNN)r   r   r   r   r   r6   r!   r   r   r#   r#   <   s   „ ñò,ð CGô&1r   r#   c                  ó*   — t        j                  «       S )z)Returns a default httplib2.Http instance.)r-   ÚHttpr!   r   r   Ú_make_default_httpr:      s   € ä�=‰=‹?Ðr   c                   óJ  — e Zd ZdZdej
                  ej                  fd„Zd„ Zddde	j                  dfd„Zdd„Zed„ «       Zej                  d	„ «       Zed
„ «       Zej                  d„ «       Zed„ «       Zej                  d„ «       Zed„ «       Zej                  d„ «       Zy)ÚAuthorizedHttpa¢  A httplib2 HTTP class with credentials.

    This class is used to perform requests to API endpoints that require
    authorization::

        from google.auth.transport._httplib2 import AuthorizedHttp

        authed_http = AuthorizedHttp(credentials)

        response = authed_http.request(
            'https://www.googleapis.com/storage/v1/b')

    This class implements :meth:`request` in the same way as
    :class:`httplib2.Http` and can usually be used just like any other
    instance of :class:`httplib2.Http`.

    The underlying :meth:`request` implementation handles adding the
    credentials' headers to the request and refreshing credentials as needed.
    Nc                 óˆ   — |€
t        «       }|| _        || _        || _        || _        t        | j                  «      | _        y)a˜  
        Args:
            credentials (google.auth.credentials.Credentials): The credentials
                to add to the request.
            http (httplib2.Http): The underlying HTTP object to
                use to make requests. If not specified, a
                :class:`httplib2.Http` instance will be constructed.
            refresh_status_codes (Sequence[int]): Which HTTP status codes
                indicate that credentials should be refreshed and the request
                should be retried.
            max_refresh_attempts (int): The maximum number of times to attempt
                to refresh the credentials and retry the request.
        N)r:   r%   ÚcredentialsÚ_refresh_status_codesÚ_max_refresh_attemptsr#   Ú_request)r   r>   r%   Úrefresh_status_codesÚmax_refresh_attemptss        r   r   zAuthorizedHttp.__init__™   sB   € ð* ˆ<Ü%Ó'ˆDàˆŒ	Ø&ˆÔØ%9ˆÔ"Ø%9ˆÔ"ô   §	¡	Ó*ˆ�r   c                 ó8   — | j                   j                  «        y)zCalls httplib2's Http.closeN)r%   Úcloser   s    r   rE   zAuthorizedHttp.close¹   s   € à�	‰	�‰Õr   r7   c           	      óž  ‡— |j                  dd«      }|�|j                  «       ni }	| j                  j                  | j                  |||	«       d}
t        ˆfd„t        D «       «      r‰j                  «       }
 | j                  j                  ||f‰|	||dœ|¤Ž\  }}|j                  | j                  v r“|| j                  k  r„t        j                  d|j                  |dz   | j                  «       | j                  j                  | j                  «       |
�‰j!                  |
«        | j                  ||f‰||||dz   dœ|¤ŽS ||fS )	z*Implementation of httplib2's Http.request.Ú_credential_refresh_attemptr   Nc              3   ó8   •K  — | ]  }t        ‰|d «      –— Œ y ­wr   )Úgetattr)Ú.0Ústream_propr(   s     €r   ú	<genexpr>z)AuthorizedHttp.request.<locals>.<genexpr>Ô   s   øè ø€ ÒV°KŒw�t˜[¨$×/ÑVùs   ƒ)r(   r   ÚredirectionsÚconnection_typez;Refreshing credentials due to a %s response. Attempt %s/%s.é   )r(   r   rM   rN   rG   )ÚpopÚcopyr>   Úbefore_requestrA   ÚallÚ_STREAM_PROPERTIESr   r%   r,   r   r?   r@   r)   ÚinfoÚrefreshr   )r   Úurir'   r(   r   rM   rN   r4   rG   Úrequest_headersÚbody_stream_positionr   Úcontents      `         r   r,   zAuthorizedHttp.request½   sr  ø€ ð '-§j¡jÐ1NÐPQÓ&RÐ#ð -4Ð,?˜'Ÿ,™,œ.ÀRˆà×Ñ×'Ñ'¨¯©°v¸sÀOÔTð  $ÐÜÓVÔCUÔVÔVØ#'§9¡9£;Ð ð .˜DŸI™I×-Ñ-ØØð
ð Ø#Ø%Ø+ñ
ð ñ
Ñˆ�'ð  �O‰O˜t×9Ñ9Ñ9Ø+¨d×.HÑ.HÒHä�L‰LØMØ—‘Ø+¨aÑ/Ø×*Ñ*ô	ð ×Ñ×$Ñ$ T§]¡]Ô3ð $Ð/Ø—	‘	Ð.Ô/ð  �4—<‘<ØØð	ð ØØ)Ø /Ø,GÈ!Ñ,Kñ	ð ñ	ð 	ð ˜Ð Ð r   c                 óB   — | j                   j                  ||||¬«       y)z'Proxy to httplib2.Http.add_certificate.)ÚpasswordN)r%   Úadd_certificate)r   ÚkeyÚcertÚdomainr\   s        r   r]   zAuthorizedHttp.add_certificate  s   € à�	‰	×!Ñ! # t¨V¸hÐ!ÕGr   c                 ó.   — | j                   j                  S )ú#Proxy to httplib2.Http.connections.©r%   Úconnectionsr   s    r   rd   zAuthorizedHttp.connections
  s   € ð �y‰y×$Ñ$Ð$r   c                 ó&   — || j                   _        y)rb   Nrc   ©r   Úvalues     r   rd   zAuthorizedHttp.connections  s   € ð !&ˆ�	‰	Õr   c                 ó.   — | j                   j                  S )ú(Proxy to httplib2.Http.follow_redirects.©r%   Úfollow_redirectsr   s    r   rk   zAuthorizedHttp.follow_redirects  s   € ð �y‰y×)Ñ)Ð)r   c                 ó&   — || j                   _        y)ri   Nrj   rf   s     r   rk   zAuthorizedHttp.follow_redirects  s   € ð &+ˆ�	‰	Õ"r   c                 ó.   — | j                   j                  S )úProxy to httplib2.Http.timeout.©r%   r3   r   s    r   r3   zAuthorizedHttp.timeout  s   € ð �y‰y× Ñ Ð r   c                 ó&   — || j                   _        y)rn   Nro   rf   s     r   r3   zAuthorizedHttp.timeout#  s   € ð "ˆ�	‰	Õr   c                 ó.   — | j                   j                  S )ú&Proxy to httplib2.Http.redirect_codes.©r%   Úredirect_codesr   s    r   rt   zAuthorizedHttp.redirect_codes(  s   € ð �y‰y×'Ñ'Ð'r   c                 ó&   — || j                   _        y)rr   Nrs   rf   s     r   rt   zAuthorizedHttp.redirect_codes-  s   € ð $)ˆ�	‰	Õ r   r   )r   r   r   r   r   ÚDEFAULT_REFRESH_STATUS_CODESÚDEFAULT_MAX_REFRESH_ATTEMPTSr   rE   r-   ÚDEFAULT_MAX_REDIRECTSr,   r]   r    rd   Úsetterrk   r3   rt   r!   r   r   r<   r<   „   s  „ ñð. Ø&×CÑCØ&×CÑCó+ò@ð ØØØ×3Ñ3ØóG!óRHð ñ%ó ð%ð ×Ññ&ó ð&ð ñ*ó ð*ð ×Ññ+ó ð+ð ñ!ó ð!ð ‡^�^ñ"ó ð"ð ñ(ó ð(ð ×Ññ)ó ñ)r   r<   )r   Ú
__future__r   Úhttp.clientr%   ÚloggingÚgoogle.authr   r   r-   Ú	getLoggerr   r)   rT   ÚResponser
   r#   r:   Úobjectr<   r!   r   r   ú<module>r�      sp   ðñ &å &ã Û å "Ý !Û ð ˆ'×
Ñ
˜HÓ
%€à-Ð ô�	×"Ñ"ô ô8@1ˆi×Ñô @1òFô
l)�Võ l)r   