1212 DEFAULT_TIMEOUT ,
1313)
1414from apify_client ._docs import docs_group
15- from apify_client ._http_clients import (
16- HttpClient ,
17- HttpClientAsync ,
18- ImpitHttpClient ,
19- ImpitHttpClientAsync ,
20- )
15+ from apify_client ._http_clients import HttpClient , HttpClientAsync , ImpitHttpClient , ImpitHttpClientAsync
2116from apify_client ._resource_clients import (
2217 ActorClient ,
2318 ActorClientAsync ,
7570 WebhookDispatchCollectionClientAsync ,
7671)
7772from apify_client ._statistics import ClientStatistics
73+ from apify_client ._utils import check_custom_headers
7874
7975if TYPE_CHECKING :
8076 from datetime import timedelta
@@ -143,6 +139,9 @@ def __init__(
143139 api_url = DEFAULT_API_URL if api_url is None else api_url
144140 api_public_url = DEFAULT_API_URL if api_public_url is None else api_public_url
145141
142+ if headers :
143+ check_custom_headers (self .__class__ .__name__ , headers )
144+
146145 self ._token = token
147146 """Apify API token for authentication."""
148147
@@ -481,6 +480,9 @@ def __init__(
481480 api_url = DEFAULT_API_URL if api_url is None else api_url
482481 api_public_url = DEFAULT_API_URL if api_public_url is None else api_public_url
483482
483+ if headers :
484+ check_custom_headers (self .__class__ .__name__ , headers )
485+
484486 self ._token = token
485487 """Apify API token for authentication."""
486488
@@ -573,16 +575,6 @@ async def call(self, *, method, url, **kwargs) -> HttpResponse:
573575 instance ._http_client = http_client
574576 return instance
575577
576- @cached_property
577- def _base_kwargs (self ) -> dict :
578- """Base keyword arguments for resource client construction."""
579- return {
580- 'base_url' : self ._base_url ,
581- 'public_base_url' : self ._public_base_url ,
582- 'http_client' : self .http_client ,
583- 'client_registry' : self ._client_registry ,
584- }
585-
586578 @property
587579 def token (self ) -> str | None :
588580 """The Apify API token used by the client."""
@@ -606,6 +598,16 @@ def http_client(self) -> HttpClientAsync:
606598 )
607599 return self ._http_client
608600
601+ @cached_property
602+ def _base_kwargs (self ) -> dict :
603+ """Base keyword arguments for resource client construction."""
604+ return {
605+ 'base_url' : self ._base_url ,
606+ 'public_base_url' : self ._public_base_url ,
607+ 'http_client' : self .http_client ,
608+ 'client_registry' : self ._client_registry ,
609+ }
610+
609611 def actor (self , actor_id : str ) -> ActorClientAsync :
610612 """Get the sub-client for a specific Actor.
611613
0 commit comments