
    Ѯh                     J   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(                  j0                  ej(                  j2                  ej(                  j4                  ej(                  j6                  efZ G d d	e      Z G d
 de      Zd Z y)z}Shared utilities used by both downloads and uploads.

This utilities are explicitly catered to ``requests``-like transports.
    N)common)_helpersi    =   <   c                   @    e Zd ZdZed        Zed        Zed        Zy)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/www/academy-backend.kofcorporation.com/venv/lib/python3.12/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   sC     	$ 	$ 
  
  	  	 r   r   c                       e Zd Zed        Zy)RawRequestsMixinc                     | j                   du r<dj                  | j                  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   sQ     % ###$:5#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}~nId}~wt        j
                  $ r0} ||j                        t        j                  v r|}n Y d}~nd}~ww xY wt        j                  ||j                  |j                        \  }}	|dz  }||	z  }|j                  ||      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   N   )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   s    4 KKn223n6O6OOI 	vH O ) 	E%% 	 qzz*f.>.>> 	  (<<~//1J1J 
	9 	qy  ++KEK

99 s    4 	B
AB
&BB
)!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      s   
     ) +.&..0      	KKKKKK  '',,  $$## * F * Z!} !&?r   