
    @f                        d Z ddlZddlZddlZddlZddlm	Z	 ddlm
Z
  e	j                    ZdZdZdZej        j        ej        j        ej        j        ej        j        ej        j        ej        j        ej        j        ej        j        ej        j        ej        j        efZ G d d	e          Z G d
 de          Zd Z dS )z}Shared utilities used by both downloads and uploads.

This utilities are explicitly catered to ``requests``-like transports.
    N)common)_helpersi    =   <   c                   T    e Zd ZdZed             Zed             Zed             ZdS )RequestsMixinzMix-in class implementing ``requests``-specific behavior.

    These are methods that are more general purpose, with implementations
    specific to the types defined in ``requests``.
    c                     | j         S )zAccess the status code from an HTTP response.

        Args:
            response (~requests.Response): The HTTP response object.

        Returns:
            int: The status code.
        )status_coderesponses    /home/panchajanya/Development/work/volatility3/lib/python3.11/site-packages/google/resumable_media/requests/_request_helpers.py_get_status_codezRequestsMixin._get_status_code<   s     ##    c                     | j         S )a
  Access the headers from an HTTP response.

        Args:
            response (~requests.Response): The HTTP response object.

        Returns:
            ~requests.structures.CaseInsensitiveDict: The header mapping (keys
            are case-insensitive).
        )headersr   s    r   _get_headerszRequestsMixin._get_headersH   s     r   c                     | j         S )Access the response body from an HTTP response.

        Args:
            response (~requests.Response): The HTTP response object.

        Returns:
            bytes: The body of the ``response``.
        )contentr   s    r   	_get_bodyzRequestsMixin._get_bodyU   s     r   N)__name__
__module____qualname____doc__staticmethodr   r   r    r   r   r   r   5   so          	$ 	$ \	$ 
  
  \
  	  	  \	  	  	 r   r   c                   $    e Zd Zed             ZdS )RawRequestsMixinc                     | j         du r@d                    | j                            t          d                    | _         d| _        | j         S )r   Fr   )decode_contentT)_contentjoinrawstream_SINGLE_GET_CHUNK_SIZE_content_consumedr   s    r   r   zRawRequestsMixin._get_bodyc   sT     %% ###$:5#QQ! !H *.H&  r   N)r   r   r   r   r   r   r   r   r   r   b   s-        ! ! \! ! !r   r   c                    d}d}t          |j                  |j        z  }	 d}	  |             }|S # t          $ r}|}Y d}~n?d}~wt          j        $ r*} ||j                  t          j        v r|}n Y d}~nd}~ww xY wt          j	        ||j
        |j                  \  }}	|dz  }||	z  }|                    ||          s|t          j        |	           )a.  Attempts to retry a call to ``func`` until success.

    Expects ``func`` to return an HTTP response and uses ``get_status_code``
    to check if the response is retry-able.

    ``func`` is expected to raise a failure status code as a
    common.InvalidResponse, at which point this method will check the code
    against the common.RETRIABLE list of retriable status codes.

    Will retry until :meth:`~.RetryStrategy.retry_allowed` (on the current
    ``retry_strategy``) returns :data:`False`. Uses
    :func:`_helpers.calculate_retry_wait` to double the wait time (with jitter)
    after each attempt.

    Args:
        func (Callable): A callable that takes no arguments and produces
            an HTTP response which will be checked as retry-able.
        get_status_code (Callable[Any, int]): Helper to get a status code
            from a response.
        retry_strategy (~google.resumable_media.common.RetryStrategy): The
            strategy to use if the request fails and must be retried.

    Returns:
        object: The return value of ``func``.
    g        r   TN   )floatinitial_delay
multiplier_CONNECTION_ERROR_CLASSESr   InvalidResponser   	RETRYABLEr   calculate_retry_wait	max_sleepretry_allowedtimesleep)
funcget_status_coderetry_strategytotal_sleepnum_retries	base_waiterrorr   e	wait_times
             r   wait_and_retryr=   u   s3   4 KKn233n6OOI	tvvH O ) 	 	 	EEEEEE% 	 	 	 qz**f.>>> 	  (<~/1J 
  
	9 	qy  ++KEE 	K
99s    
1 
A>AA> A99A>)!r   http.clienthttprequests.exceptionsrequestsurllib3.exceptionsurllib3r2   google.resumable_mediar   r   RetryStrategy_DEFAULT_RETRY_STRATEGYr%   _DEFAULT_CONNECT_TIMEOUT_DEFAULT_READ_TIMEOUTclientBadStatusLineIncompleteReadResponseNotReady
exceptionsConnectionErrorChunkedEncodingErrorTimeout	PoolErrorProtocolErrorSSLErrorTimeoutErrorr,   objectr   r   r=   r   r   r   <module>rV      sY   
              ) ) ) ) ) ) + + + + + +.&.00      	KKK ', $# *  *  *  *  * F *  *  * Z! ! ! ! !} ! ! !&? ? ? ? ?r   