;i'dZddlmZddlZddlZddlmZddlmZddl Z ej e Z dZ GddejZGd d ejZd ZGd d eZdS)zTransport adapter for httplib2.)absolute_importN) exceptions) transport)readseektellcZeZdZdZdZedZedZedZdS) _Responsezhttplib2 transport response adapter. Args: response (httplib2.Response): The raw httplib2 response. data (bytes): The response body. c"||_||_dSN) _response_data)selfresponsedatas HC:\PYTHON\MyICR_Workspace\venv\Lib\site-packages\google_auth_httplib2.py__init__z_Response.__init__(s! c|jjS)zint: The HTTP status code.)r statusrs rrz_Response.status,s~$$rc*t|jS)z-Mapping[str, str]: The HTTP response headers.)dictr rs rheadersz_Response.headers1sDN###rc|jS)zbytes: The response body.)rrs rrz_Response.data6s zrN) __name__ __module__ __qualname____doc__rpropertyrrrrrr r s~%%X%$$X$Xrr c"eZdZdZdZ ddZdS)Requestahttplib2 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||_dSr )http)rr%s rrzRequest.__init__Ss  rGETNc @|td td|||jj|f|||d|\}}t ||S#t jtjj f$r} tj | d} ~ wwxYw)a3Make 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.zMaking request: %s %s)methodbodyr) _LOGGERwarningdebugr%requestr httplib2 HttpLib2Errorclient HTTPExceptionrTransportError) rurlr(r)rtimeoutkwargsrrexcs r__call__zRequest.__call__Vs.   OOP    1 MM163 ? ? ?.TY."wBHNHdXt,, ,& (AB 1 1 1+C00 0 1sAA$$ BBB)r&NNN)rrrrrr7r!rrr#r#<sH,CG&1&1&1&1&1&1rr#c(tjS)z)Returns a default httplib2.Http instance.)r.Httpr!rr_make_default_httpr:s =??rc6eZdZdZdejejfdZdZddde j dfdZ ddZ e dZejd Ze d Zejd Ze d Zejd Ze dZejdZdS)AuthorizedHttpaA 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|_dS)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)rr>r%refresh_status_codesmax_refresh_attemptss rrzAuthorizedHttp.__init__sJ* <%''D &%9"%9"  ** rc8|jdS)zCalls httplib2's Http.closeN)r%closers rrEzAuthorizedHttp.closes rr&c r|dd}||ni} |j|j||| d} t fdt Dr} |jj ||f| ||d|\} } | j |j vr||j krxtd| j |dz|j |j|j| | |j ||f||||dzd|S| | fS) z*Implementation of httplib2's Http.request._credential_refresh_attemptrNc3:K|]}t|dVdSr )getattr).0 stream_propr)s r z)AuthorizedHttp.request..s/VVKwt[$//VVVVVVr)r)r redirectionsconnection_typez;Refreshing credentials due to a %s response. Attempt %s/%s.)r)rrMrNrG)popcopyr>before_requestrAall_STREAM_PROPERTIESrr%r-rr?r@r*inforefreshr) rurir(r)rrMrNr5rGrequest_headersbody_stream_positionrcontents ` rr-zAuthorizedHttp.requests'-jj1NPQ&R&R#-4,?',,...R '' vsOTTT $ VVVVCUVVV V V /#'99;; .DI-   #%+     ' Ot9 9 9+d.HHH LLM+a/*       $ $T] 3 3 3$/ ./// 4< ) /,G!,K       rcB|j||||dS)z'Proxy to httplib2.Http.add_certificate.)passwordN)r%add_certificate)rkeycertdomainr\s rr]zAuthorizedHttp.add_certificates' !!#tVh!GGGGGrc|jjS)#Proxy to httplib2.Http.connections.r% connectionsrs rrdzAuthorizedHttp.connections sy$$rc||j_dS)rbNrcrvalues rrdzAuthorizedHttp.connectionss!& rc|jjS)(Proxy to httplib2.Http.follow_redirects.r%follow_redirectsrs rrkzAuthorizedHttp.follow_redirectssy))rc||j_dS)riNrjrfs rrkzAuthorizedHttp.follow_redirectss&+ """rc|jjS)Proxy to httplib2.Http.timeout.r%r4rs rr4zAuthorizedHttp.timeoutsy  rc||j_dS)rnNrorfs rr4zAuthorizedHttp.timeout#s" rc|jjS)&Proxy to httplib2.Http.redirect_codes.r%redirect_codesrs rrtzAuthorizedHttp.redirect_codes(sy''rc||j_dS)rrNrsrfs rrtzAuthorizedHttp.redirect_codes-s$)    rr )rrrrrDEFAULT_REFRESH_STATUS_CODESDEFAULT_MAX_REFRESH_ATTEMPTSrrEr.DEFAULT_MAX_REDIRECTSr-r]r rdsetterrkr4rtr!rrr<r<s~.&C&C ++++@ 3G!G!G!G!RHHHH%%X%&&&**X*+++!!X! ^""^"((X()))))rr<)r __future__r http.clientr%logging google.authrrr. getLoggerrr*rTResponser r#r:objectr<r!rrrs+&%&&&&&&""""""!!!!!! ' H % %- "8@1@1@1@1@1i@1@1@1F l)l)l)l)l)Vl)l)l)l)l)r