Ë
    8ø»j?)  ã                  óJ  — d dl mZ d dlmZ d dlZd dlmZ d dlmZm	Z	m
Z
mZmZmZ d dlmZ d dlmZmZ erd dlmZ d d	lmZ d d
lmZ ej2                  ej4                  ej6                  ej8                  fZ	  ed«       G d„ de«      «       Z ed«       G d„ de«      «       Zy)é    )Úannotations)ÚTYPE_CHECKINGN)Úoverride)ÚDEFAULT_MAX_RETRIESÚ!DEFAULT_MIN_DELAY_BETWEEN_RETRIESÚDEFAULT_TIMEOUT_LONGÚDEFAULT_TIMEOUT_MAXÚDEFAULT_TIMEOUT_MEDIUMÚDEFAULT_TIMEOUT_SHORT)Ú
docs_group)Ú
HttpClientÚHttpClientAsync)Ú	timedelta)ÚClientStatistics)ÚHttpCompressorzHTTP clientsc                  óÎ   ‡ — e Zd ZdZdeeeeee	ddddœ
	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 d	ˆ fd„Z
ed
ˆ fd„«       Zed
d„«       Zedd„«       Ze	 	 	 	 	 	 	 	 	 	 	 	 	 	 dd„«       Zˆ xZS )ÚImpitHttpClienta   Synchronous HTTP client for the Apify API built on top of [Impit](https://github.com/apify/impit).

    Impit is a high-performance HTTP client written in Rust that provides browser-like TLS fingerprints,
    automatic header ordering, and HTTP/2 support. This client wraps `impit.Client` and adds automatic retries
    with exponential backoff for rate-limited (HTTP 429) and server error (HTTP 5xx) responses.
    N©
ÚtokenÚtimeout_shortÚtimeout_mediumÚtimeout_longÚtimeout_maxÚmax_retriesÚmin_delay_between_retriesÚ
statisticsÚheadersÚhttp_compressorc       
        ón   •— t         ‰| �  |||||||||	|
¬«
       t        j                  d¬«      | _        y)a  Initialize the Impit-based synchronous HTTP client.

        Args:
            token: Apify API token for authentication.
            timeout_short: Default timeout for short-duration API operations (simple CRUD operations, ...).
            timeout_medium: Default timeout for medium-duration API operations (batch operations, listing, ...).
            timeout_long: Default timeout for long-duration API operations (long-polling, streaming, ...).
            timeout_max: Maximum timeout cap for any single request attempt, including tier and per-call timeouts.
            max_retries: Maximum number of retry attempts for failed requests.
            min_delay_between_retries: Minimum delay between retries (increases exponentially with each attempt).
            statistics: Statistics tracker for API calls. Created automatically if not provided.
            headers: Additional HTTP headers to include in all requests.
            http_compressor: Compressor used to compress request bodies. Defaults to `GzipHttpCompressor`.
        r   T©Úfollow_redirectsN)ÚsuperÚ__init__ÚimpitÚClientÚ_impit_client©Úselfr   r   r   r   r   r   r   r   r   r   Ú	__class__s              €úW/var/www/html/GAP/venv/lib/python3.12/site-packages/apify_client/http_clients/_impit.pyr#   zImpitHttpClient.__init__3   sH   ø€ ô8 	‰ÑØØ'Ø)Ø%Ø#Ø#Ø&?Ø!ØØ+ð 	ô 	
ô #Ÿ\™\¸4Ô@ˆÕó    c                óZ   •— t         ‰| �  |«      xs t        |t        j                  «      S ©N©r"   Úis_timeout_errorÚ
isinstancer$   ÚTimeoutException©r(   Úexcr)   s     €r*   r/   z ImpitHttpClient.is_timeout_error^   ó%   ø€ ä‰wÑ'¨Ó,ÒW´
¸3Ä×@VÑ@VÓ0WÐWr+   c                ó\   — t        |t        j                  «      xr t        |t        «       S r-   ©r0   r$   Ú	HTTPErrorÚ_PERMANENT_ERRORS©r(   r3   s     r*   Úis_retryable_transport_errorz,ImpitHttpClient.is_retryable_transport_errorb   ó%   € ô ˜#œuŸ™Ó/ÒZ¼
À3ÔHYÓ8ZÐ4ZÐZr+   c                ó>   — | j                   j                  ddd«       y)a   Release resources owned by this client.

        Delegates to Impit's own teardown, which releases nothing and leaves the client usable, because Impit
        doesn't expose a way to close its connection pool. Routing through it keeps this client correct once
        Impit does.
        N)r&   Ú__exit__©r(   s    r*   ÚclosezImpitHttpClient.closek   s   € ð 	×Ñ×#Ñ# D¨$°Õ5r+   c               óP   — |€dn|}| j                   j                  ||||||¬«      S ©Ni€Q )ÚmethodÚurlr   ÚcontentÚtimeoutÚstream)r&   Úrequest©r(   rB   rC   r   rD   rE   rF   Úimpit_timeouts           r*   Úsend_requestzImpitHttpClient.send_requestu   s?   € ð #* /™°wˆØ×!Ñ!×)Ñ)ØØØØØ!Øð *ó 
ð 	
r+   ©r   z
str | Noner   r   r   r   r   r   r   r   r   Úintr   r   r   zClientStatistics | Noner   zdict[str, str] | Noner   zHttpCompressor | NoneÚreturnÚNone©r3   Ú	ExceptionrM   Úbool©rM   rN   ©rB   ÚstrrC   rT   r   zdict[str, str]rD   zbytes | NonerE   zfloat | NonerF   rQ   rM   zimpit.Response)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r
   r   r	   r   r   r#   r   r/   r:   r?   rJ   Ú__classcell__©r)   s   @r*   r   r   *   sB  ø„ ñð !Ø#8Ø$:Ø"6Ø!4Ø.Ø/PØ.2Ø)-Ø15ñ)Að ð)Að !ð	)Að
 "ð)Að  ð)Að ð)Að ð)Að $-ð)Að ,ð)Að 'ð)Að /ð)Að 
õ)AðV ôXó ðXð ò[ó ð[ð ò6ó ð6ð ð
ð ð
ð ð	
ð
  ð
ð ð
ð ð
ð ð
ð 
ò
ó ô
r+   r   c                  óÎ   ‡ — e Zd ZdZdeeeeee	ddddœ
	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 d	ˆ fd„Z
ed
ˆ fd„«       Zed
d„«       Zedd„«       Ze	 	 	 	 	 	 	 	 	 	 	 	 	 	 dd„«       Zˆ xZS )ÚImpitHttpClientAsynca¦  Asynchronous HTTP client for the Apify API built on top of [Impit](https://github.com/apify/impit).

    Impit is a high-performance HTTP client written in Rust that provides browser-like TLS fingerprints,
    automatic header ordering, and HTTP/2 support. This client wraps `impit.AsyncClient` and adds automatic retries
    with exponential backoff for rate-limited (HTTP 429) and server error (HTTP 5xx) responses.
    Nr   c       
        ón   •— t         ‰| �  |||||||||	|
¬«
       t        j                  d¬«      | _        y)a  Initialize the Impit-based asynchronous HTTP client.

        Args:
            token: Apify API token for authentication.
            timeout_short: Default timeout for short-duration API operations (simple CRUD operations, ...).
            timeout_medium: Default timeout for medium-duration API operations (batch operations, listing, ...).
            timeout_long: Default timeout for long-duration API operations (long-polling, streaming, ...).
            timeout_max: Maximum timeout cap for any single request attempt, including tier and per-call timeouts.
            max_retries: Maximum number of retry attempts for failed requests.
            min_delay_between_retries: Minimum delay between retries (increases exponentially with each attempt).
            statistics: Statistics tracker for API calls. Created automatically if not provided.
            headers: Additional HTTP headers to include in all requests.
            http_compressor: Compressor used to compress request bodies. Defaults to `GzipHttpCompressor`.
        r   Tr    N)r"   r#   r$   ÚAsyncClientÚ_impit_async_clientr'   s              €r*   r#   zImpitHttpClientAsync.__init__—   sJ   ø€ ô8 	‰ÑØØ'Ø)Ø%Ø#Ø#Ø&?Ø!ØØ+ð 	ô 	
ô $)×#4Ñ#4ÀdÔ#KˆÕ r+   c                óZ   •— t         ‰| �  |«      xs t        |t        j                  «      S r-   r.   r2   s     €r*   r/   z%ImpitHttpClientAsync.is_timeout_errorÂ   r4   r+   c                ó\   — t        |t        j                  «      xr t        |t        «       S r-   r6   r9   s     r*   r:   z1ImpitHttpClientAsync.is_retryable_transport_errorÆ   r;   r+   c              ƒ  óZ   K  — | j                   j                  ddd«      ƒ d{  –—†  y7 Œ­w)zuRelease resources owned by this client.

        See `ImpitHttpClient.close` for what Impit's teardown does.
        N)r_   Ú	__aexit__r>   s    r*   ÚaclosezImpitHttpClientAsync.acloseÏ   s&   è ø€ ð ×&Ñ&×0Ñ0°°t¸TÓB×BÒBús   ‚!+£)¤+c             ƒ  ól   K  — |€dn|}| j                   j                  ||||||¬«      ƒ d {  –—† S 7 Œ­wrA   )r_   rG   rH   s           r*   rJ   z!ImpitHttpClientAsync.send_request×   sM   è ø€ ð #* /™°wˆØ×-Ñ-×5Ñ5ØØØØØ!Øð 6ó 
÷ 
ð 	
ð 
ús   ‚+4­2®4rK   rO   rR   rS   )rU   rV   rW   rX   r   r
   r   r	   r   r   r#   r   r/   r:   rd   rJ   rY   rZ   s   @r*   r\   r\   Ž   sD  ø„ ñð !Ø#8Ø$:Ø"6Ø!4Ø.Ø/PØ.2Ø)-Ø15ñ)Lð ð)Lð !ð	)Lð
 "ð)Lð  ð)Lð ð)Lð ð)Lð $-ð)Lð ,ð)Lð 'ð)Lð /ð)Lð 
õ)LðV ôXó ðXð ò[ó ð[ð òCó ðCð ð
ð ð
ð ð	
ð
  ð
ð ð
ð ð
ð ð
ð 
ò
ó ô
r+   r\   ) Ú
__future__r   Útypingr   r$   Útyping_extensionsr   Úapify_client._constsr   r   r   r	   r
   r   Úapify_client._docsr   Úapify_client.http_clients._baser   r   Údatetimer   Úapify_client._statisticsr   Ú#apify_client.http_compressors._baser   ÚLocalProtocolErrorÚUnsupportedProtocolÚTooManyRedirectsÚHTTPStatusErrorr8   r   r\   © r+   r*   ú<module>rt      s®   ðÝ "å  ã Ý &÷÷ õ *ß GáÝ"å9ÝBð
 
×Ñð 
×Ñà	×Ñð 
×ÑðÐ ð oñ ˆNÓô`
�jó `
ó ð`
ñF ˆNÓô\
˜?ó \
ó ñ\
r+   