
    (ph'                         S r SSKJr  SSKrSSKrSSKJr  SSKJr  SSK	r	\R                  " \5      rSr " S S\R                  5      r " S	 S
\R                   5      rS r " S S\5      rg)zTransport adapter for httplib2.    )absolute_importN)
exceptions)	transport)readseektellc                   N    \ rS rSrSrS r\S 5       r\S 5       r\S 5       r	Sr
g)		_Response    zhttplib2 transport response adapter.

Args:
    response (httplib2.Response): The raw httplib2 response.
    data (bytes): The response body.
c                     Xl         X l        g N)	_response_data)selfresponsedatas      G/var/www/html/venv/lib/python3.13/site-packages/google_auth_httplib2.py__init___Response.__init__(   s    !
    c                 .    U R                   R                  $ )zint: The HTTP status code.)r   statusr   s    r   r   _Response.status,   s     ~~$$$r   c                 ,    [        U R                  5      $ )z-Mapping[str, str]: The HTTP response headers.)dictr   r   s    r   headers_Response.headers1   s     DNN##r   c                     U R                   $ )zbytes: The response body.)r   r   s    r   r   _Response.data6   s     zzr   )r   r   N)__name__
__module____qualname____firstlineno____doc__r   propertyr   r   r   __static_attributes__ r   r   r
   r
       sH     % % $ $  r   r
   c                   *    \ rS rSrSrS r SS jrSrg)Request<   ag  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                     Xl         g r   http)r   r.   s     r   r   Request.__init__U   s    	r   Nc                 R   Ub  [         R                  S5         [         R                  SX!5        U R                  R                  " U4X#US.UD6u  px[        Xx5      $ ! [        R                  [        R                  R                  4 a  n	[        R                  " U	5      eSn	A	ff = f)a  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   urlr1   r2   r   timeoutkwargsr   r   excs
             r   __call__Request.__call__X   s    . OOP
		1MM16?!YY.."wBHNH X,, &&(A(AB 	1++C00	1s   AA .B&B!!B&r-   )GETNNN)r!   r"   r#   r$   r%   r   r@   r'   r(   r   r   r*   r*   <   s    0 CG&1r   r*   c                  ,    [         R                  " 5       $ )z)Returns a default httplib2.Http instance.)r7   Httpr(   r   r   _make_default_httprE      s    ==?r   c                   X   \ rS rSrSrS\R                  \R                  4S jrS r	SSS\
R                  S4S jrSS jr\S	 5       r\R                   S
 5       r\S 5       r\R                   S 5       r\S 5       r\R                   S 5       r\S 5       r\R                   S 5       rSrg)AuthorizedHttp   as  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                     Uc
  [        5       nX l        Xl        X0l        X@l        [        U R                  5      U l        g)a8  
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)rE   r.   credentials_refresh_status_codes_max_refresh_attemptsr*   _request)r   rJ   r.   refresh_status_codesmax_refresh_attemptss        r   r   AuthorizedHttp.__init__   s:    * <%'D	&%9"%9"  		*r   c                 8    U R                   R                  5         g)zCalls httplib2's Http.closeN)r.   closer   s    r   rR   AuthorizedHttp.close   s    		r   rB   c           	        ^ UR                  SS5      nUb  UR                  5       O0 n	U R                  R                  U R                  X!U	5        Sn
[        U4S j[         5       5      (       a  TR                  5       n
U R                  R                  " UU4TU	UUS.UD6u  pUR                  U R                  ;   a  XR                  :  a  [        R                  SUR                  US-   U R                  5        U R                  R                  U R                  5        U
b  TR!                  U
5        U R                  " UU4TUUUUS-   S.UD6$ X4$ )	z*Implementation of httplib2's Http.request._credential_refresh_attemptr   Nc              3   >   >#    U  H  n[        TUS 5      v   M     g 7fr   )getattr).0stream_propr2   s     r   	<genexpr>)AuthorizedHttp.request.<locals>.<genexpr>   s     VCUKwt[$//CUs   )r2   r   redirectionsconnection_typez;Refreshing credentials due to a %s response. Attempt %s/%s.   )r2   r   r\   r]   rU   )popcopyrJ   before_requestrM   all_STREAM_PROPERTIESr   r.   r6   r   rK   rL   r3   inforefreshr   )r   urir1   r2   r   r\   r]   r>   rU   request_headersbody_stream_positionr   contents      `         r   r6   AuthorizedHttp.request   sk    '-jj1NPQ&R# -4,?',,.R''vOT  $VCUVVV#'99;  !II--
 #%+
 
  OOt999+.H.HH LLM+a/**	 $$T]]3 $/		./ <<	 ) /,G!,K	 	 	   r   c                 8    U R                   R                  XX4S9  g)z'Proxy to httplib2.Http.add_certificate.)passwordN)r.   add_certificate)r   keycertdomainrl   s        r   rm   AuthorizedHttp.add_certificate	  s    		!!#V!Gr   c                 .    U R                   R                  $ )#Proxy to httplib2.Http.connections.r.   connectionsr   s    r   ru   AuthorizedHttp.connections  s     yy$$$r   c                 $    XR                   l        g)rs   Nrt   r   values     r   ru   rv     s     !&		r   c                 .    U R                   R                  $ )(Proxy to httplib2.Http.follow_redirects.r.   follow_redirectsr   s    r   r}   AuthorizedHttp.follow_redirects  s     yy)))r   c                 $    XR                   l        g)r{   Nr|   rx   s     r   r}   r~     s     &+		"r   c                 .    U R                   R                  $ )Proxy to httplib2.Http.timeout.r.   r=   r   s    r   r=   AuthorizedHttp.timeout!  s     yy   r   c                 $    XR                   l        g)r   Nr   rx   s     r   r=   r   &  s     "		r   c                 .    U R                   R                  $ )&Proxy to httplib2.Http.redirect_codes.r.   redirect_codesr   s    r   r   AuthorizedHttp.redirect_codes+  s     yy'''r   c                 $    XR                   l        g)r   Nr   rx   s     r   r   r   0  s     $)		 r   )rL   rK   rM   rJ   r.   r   )r!   r"   r#   r$   r%   r   DEFAULT_REFRESH_STATUS_CODESDEFAULT_MAX_REFRESH_ATTEMPTSr   rR   r7   DEFAULT_MAX_REDIRECTSr6   rm   r&   ru   setterr}   r=   r   r'   r(   r   r   rG   rG      s   . &CC&CC+@ 33H!TH % % & & * * + + ! ! ^^" " ( ( ) )r   rG   )r%   
__future__r   http.clientr.   logginggoogle.authr   r   r7   	getLoggerr!   r3   rc   Responser
   r*   rE   objectrG   r(   r   r   <module>r      sn    & &   " !  

H
%- 	"" 8B1i B1J
m)V m)r   