
    rh'                         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)	_Responsezhttplib2 transport response adapter.

    Args:
        response (httplib2.Response): The raw httplib2 response.
        data (bytes): The response body.
    c                      || _         || _        y N)	_response_data)selfresponsedatas      g/var/www/html/ai-insurance-compliance-backend/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     DNN##r   c                     | j                   S )zbytes: The response body.)r   r   s    r   r   z_Response.data6   s     zz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.

    .. automethod:: __call__
    c                     || _         y r   )http)r   r%   s     r   r   zRequest.__init__U   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__X   s    . OOP
		1MM163?.TYY.."wBHNHd Xt,, &&(A(AB 	1++C00	1s   AA   -B'B""B')GETNNN)r   r   r   r   r   r6   r!   r   r   r#   r#   <   s    0 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  rt        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     VKwt[$/Vs   )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   st    '-jj1NPQ&R# -4,?',,.R''vsOT  $VCUVV#'99;  .DII--
 #%+
 
'  OOt999+d.H.HH LL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    		!!#tVh!Gr   c                 .    | j                   j                  S )#Proxy to httplib2.Http.connections.r%   connectionsr   s    r   rd   zAuthorizedHttp.connections  s     yy$$$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     yy)))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     yy   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     yy'''r   c                 &    || j                   _        y)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   r3   rt   r!   r   r   r<   r<      s   . &CC&CC+@ 33H!T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
%- 	"" 8B1i B1J
m)V m)r   