
    &g'                         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dS )zTransport adapter for httplib2.    )absolute_importN)
exceptions)	transport)readseektellc                   Z    e Zd ZdZd Zed             Zed             Zed             ZdS )	_Responsezhttplib2 transport response adapter.

    Args:
        response (httplib2.Response): The raw httplib2 response.
        data (bytes): The response body.
    c                 "    || _         || _        d S N)	_response_data)selfresponsedatas      F/var/www/api/venv/lib/python3.11/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     DN###r   c                     | j         S )zbytes: The response body.)r   r   s    r   r   z_Response.data6   s     zr   N)	__name__
__module____qualname____doc__r   propertyr   r   r    r   r   r
   r
       s~            % % X% $ $ X$   X  r   r
   c                   "    e Zd ZdZd Z	 ddZdS )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.

    .. automethod:: __call__
    c                     || _         d S r   )http)r   r%   s     r   r   zRequest.__init__U   s    			r   GETNc                 @   |t                               d           	 t                               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__X   s    . OOP  
		1MM163???.TY."w BH NHd Xt,,, &(AB 	1 	1 	1+C000	1s   AA$ $ BBB)r&   NNN)r   r   r   r   r   r7   r!   r   r   r#   r#   <   sH         0   CG&1 &1 &1 &1 &1 &1r   r#   c                  (    t          j                    S )z)Returns a default httplib2.Http instance.)r.   Httpr!   r   r   _make_default_httpr:      s    =??r   c                   6   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dS )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                  | _        dS )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__   sJ    * <%''D	&%9"%9"  	**r   c                 8    | j                                          dS )zCalls httplib2's Http.closeN)r%   closer   s    r   rE   zAuthorizedHttp.close   s    	r   r&   c           	      r   |                     dd          }||                                ni }	| j                            | j        |||	           d}
t          fdt          D                       r                                }
 | j        j	        ||f|	||d|\  }}|j
        | j        v r|| j        k     rxt                              d|j
        |dz   | j                   | j                            | j                   |
                    |
            | j	        ||f||||dz   d|S ||fS )	z*Implementation of httplib2's Http.request._credential_refresh_attemptr   Nc              3   :   K   | ]}t          |d           V  d S r   )getattr).0stream_propr)   s     r   	<genexpr>z)AuthorizedHttp.request.<locals>.<genexpr>   s/      VVKwt[$//VVVVVVr   )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   r5   rG   request_headersbody_stream_positionr   contents      `         r   r-   zAuthorizedHttp.request   s    '-jj1NPQ&R&R# -4,?',,...R''vsOTTT  $VVVVCUVVVVV 	/#'99;;  .DI-
 #%+
 
 
 
'  Ot999+d.HHH LLM+a/*	   $$T]333 $/		.///  4<	 ) /,G!,K	 	 	 	 	   r   c                 B    | j                             ||||           dS )z'Proxy to httplib2.Http.add_certificate.)passwordN)r%   add_certificate)r   keycertdomainr\   s        r   r]   zAuthorizedHttp.add_certificate	  s'    	!!#tVh!GGGGGr   c                     | j         j        S )#Proxy to httplib2.Http.connections.r%   connectionsr   s    r   rd   zAuthorizedHttp.connections  s     y$$r   c                     || j         _        dS )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))r   c                     || j         _        dS )ri   Nrj   rf   s     r   rk   zAuthorizedHttp.follow_redirects  s     &+	"""r   c                     | j         j        S )Proxy to httplib2.Http.timeout.r%   r4   r   s    r   r4   zAuthorizedHttp.timeout!  s     y  r   c                     || j         _        dS )rn   Nro   rf   s     r   r4   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''r   c                     || j         _        dS )rr   Nrs   rf   s     r   rt   zAuthorizedHttp.redirect_codes0  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   r4   rt   r!   r   r   r<   r<      s~        . &C&C+ + + +@   3H! H! H! H!TH H H H % % X% & & & * * X* + + + ! ! X! ^" " ^" ( ( X( ) ) ) ) )r   r<   )r   
__future__r   http.clientr%   logginggoogle.authr   r   r.   	getLoggerr   r*   rT   Responser
   r#   r:   objectr<   r!   r   r   <module>r      s+   & % & & & & & &      " " " " " " ! ! ! ! ! !  '
H
%
%-     	"   8B1 B1 B1 B1 B1i B1 B1 B1J  
m) m) m) m) m)V m) m) m) m) m)r   