+
    }i                    h   ^ RI Ht ^ RIHtHt ^ RIHt ^ RIHtH	t	 ^ RI
Ht ]'       d;   ^ RIHt ^ RIHt ^ RIHt ^ R	IHt ^ R
IHt ^ RIHtHtHt ^ RIHt ^ RIHt ^ RIHt ]! R4       ! R R]	4      4       t ]! RR7      ]! R4       ! R R4      4       4       t!]! R4       ! R R]4      4       t"R# )    )annotations)ABCabstractmethod)	dataclass)TYPE_CHECKINGProtocol)
docs_group)AsyncIterator)AbstractAsyncContextManager)	timedelta)TracebackType)Request)HttpHeaders
HttpMethodHttpPayload)	ProxyInfo)Session)
StatisticsOtherc                  t    ] tR t^tRt]R R l4       t]R R l4       t]R R l4       tR R	 lt	R
 R lt
RtR# )HttpResponsezBDefine the interface that any HTTP response object must implement.c                   V ^8  d   QhRR/# )   returnstr )formats   "l/Users/ahmad/.openclaw/workspace/my-crawler/.venv/lib/python3.14/site-packages/crawlee/http_clients/_base.py__annotate__HttpResponse.__annotate__   s     5 5c 5    c                    R# )z&The HTTP version used in the response.Nr   selfs   &r   http_versionHttpResponse.http_version       r!   c                   V ^8  d   QhRR/# )r   r   intr   )r   s   "r   r   r       s     = =S =r!   c                    R# )z.The HTTP status code received from the server.Nr   r#   s   &r   status_codeHttpResponse.status_code   r'   r!   c                   V ^8  d   QhRR/# )r   r   r   r   )r   s   "r   r   r    #   s     9 9 9r!   c                    R# )z*The HTTP headers received in the response.Nr   r#   s   &r   headersHttpResponse.headers"   r'   r!   c                   V ^8  d   QhRR/# )r   r   bytesr   )r   s   "r   r   r    &   s      E r!   c                   "   R# 5i)a4  Read the entire content of the response body.

This method loads the complete response body into memory at once. It should be used
for responses received from regular HTTP requests (via `send_request` or `crawl` methods).

Raises:
    RuntimeError: If called on a response received from the `stream` method.
Nr   r#   s   &r   readHttpResponse.read&           c                   V ^8  d   QhRR/# )r   r   zAsyncIterator[bytes]r   )r   s   "r   r   r    0   s     
 
1 
r!   c                    R# )a  Iterate over the content of the response body in chunks.

This method should be used for responses received from the `stream` method to process
large response bodies without loading them entirely into memory. It allows for efficient
processing of potentially large data by yielding chunks sequentially.

Raises:
    RuntimeError: If the stream has already been consumed or if the response was not obtained from the `stream`
        method.
Nr   r#   s   &r   read_streamHttpResponse.read_stream0   r'   r!   r   N)__name__
__module____qualname____firstlineno____doc__propertyr%   r+   r/   r4   r:   __static_attributes__r   r!   r   r   r      sN    L5 5 = = 9 9
 
r!   r   T)frozenzCrawling contextsc                  &    ] tR t^=t$ RtR]R&   RtR# )HttpCrawlingResultzResult of an HTTP-only crawl.

Mainly for the purpose of composing specific crawling contexts (e.g. `BeautifulSoupCrawlingContext`,
`ParselCrawlingContext`, ...).
r   http_responser   N)r<   r=   r>   r?   r@   __annotations__rB   r   r!   r   rE   rE   =   s      5r!   rE   zHTTP clientsc                  
   ] tR t^JtRt]RR/R R ll4       t]R R l4       t]RR	R
R	RR	RR	/R R ll4       t	]RRRR	RR	RR	R
R	RR	/R R ll4       t
]RRRR	RR	RR	R
R	RR	/R R ll4       t]R R l4       tR R ltR R ltRtR	# )
HttpClientzUAn abstract base class for HTTP clients used in crawlers (`BasicCrawler` subclasses).persist_cookies_per_sessionTc                    V ^8  d   QhRRRR/# )r   rJ   boolr   Noner   )r   s   "r   r   HttpClient.__annotate__O   s        &* 
	r!   c                    Wn         RV n        R# )zpInitialize a new instance.

Args:
    persist_cookies_per_session: Whether to persist cookies per HTTP session.
FN)_persist_cookies_per_session_active)r$   rJ   s   &$r   __init__HttpClient.__init__N   s     -H) r!   c                   V ^8  d   QhRR/# )r   r   rL   r   )r   s   "r   r   rN   _   s       r!   c                    V P                   # )z'Indicate whether the context is active.)rQ   r#   s   &r   activeHttpClient.active^   s     ||r!   sessionN
proxy_info
statisticstimeoutc               0    V ^8  d   QhRRRRRRRRR	R
RR/# )r   requestr   rX   Session | NonerY   ProxyInfo | NonerZ   zStatistics | Noner[   timedelta | Noner   rE   r   )r   s   "r   r   rN   d   sF        	
 % & " 
r!   c                  "   R# 5i)a  Perform the crawling for a given request.

This method is called from `crawler.run()`.

Args:
    request: The request to be crawled.
    session: The session associated with the request.
    proxy_info: The information about the proxy to be used.
    statistics: The statistics object to register status codes.
    timeout: Maximum time allowed to process the request.

Raises:
    ProxyError: Raised if a proxy-related error occurs.

Returns:
    The result of the crawling.
Nr   )r$   r]   rX   rY   rZ   r[   s   &&$$$$r   crawlHttpClient.crawlc   r6   r7   methodGETr/   payloadc               8    V ^8  d   QhRRRRRRRRR	R
RRRRRR/# )r   urlr   rd   r   r/   #HttpHeaders | dict[str, str] | Nonerf   HttpPayload | NonerX   r^   rY   r_   r[   r`   r   r   r   )r   s   "r   r   rN      sZ       	
 5 $   % " 
r!   c                  "   R# 5i)aG  Send an HTTP request via the client.

This method is called from `context.send_request()` helper.

Args:
    url: The URL to send the request to.
    method: The HTTP method to use.
    headers: The headers to include in the request.
    payload: The data to be sent as the request body.
    session: The session associated with the request.
    proxy_info: The information about the proxy to be used.
    timeout: Maximum time allowed to process the request.

Raises:
    ProxyError: Raised if a proxy-related error occurs.

Returns:
    The HTTP response received from the server.
Nr   r$   rh   rd   r/   rf   rX   rY   r[   s   &&$$$$$$r   send_requestHttpClient.send_request   r6   r7   c               8    V ^8  d   QhRRRRRRRRR	R
RRRRRR/# )r   rh   r   rd   r   r/   ri   rf   rj   rX   r^   rY   r_   r[   r`   r   z)AbstractAsyncContextManager[HttpResponse]r   )r   s   "r   r   rN      sZ       	
 5 $   % " 
3r!   c                   R# )a  Stream an HTTP request via the client.

This method should be used for downloading potentially large data where you need to process
the response body in chunks rather than loading it entirely into memory.

Args:
    url: The URL to send the request to.
    method: The HTTP method to use.
    headers: The headers to include in the request.
    payload: The data to be sent as the request body.
    session: The session associated with the request.
    proxy_info: The information about the proxy to be used.
    timeout: The maximum time to wait for establishing the connection.

Raises:
    ProxyError: Raised if a proxy-related error occurs.

Returns:
    An async context manager yielding the HTTP response with streaming capabilities.
Nr   rl   s   &&$$$$$$r   streamHttpClient.stream   r'   r!   c                   V ^8  d   QhRR/# )r   r   rM   r   )r   s   "r   r   rN      s      t r!   c                   "   R# 5i)zClean up resources used by the client.

This method is called when the client is no longer needed and should be overridden
in subclasses to perform any necessary cleanup such as closing connections,
releasing file handles, or other resource deallocation.
Nr   r#   s   &r   cleanupHttpClient.cleanup   r6   r7   c                   V ^8  d   QhRR/# )r   r   rI   r   )r   s   "r   r   rN      s     
 
* 
r!   c                   "   V P                   '       d$   \        RV P                  P                   R24      hRV n         V # 5i)z~Initialize the client when entering the context manager.

Raises:
    RuntimeError: If the context manager is already active.
The z is already active.T)rQ   RuntimeError	__class__r<   r#   s   &r   
__aenter__HttpClient.__aenter__   s<      <<<dnn&=&=%>>QRSSs   ?Ac               (    V ^8  d   QhRRRRRRRR/# )r   exc_typezBaseException | None	exc_value	tracebackzTracebackType | Noner   rM   r   )r   s   "r   r   rN      s,      ,9MZn	r!   c                   "   V P                   '       g$   \        RV P                  P                   R24      hV P	                  4       G Rj  xL
  RV n         R#  L5i)zDeinitialize the client and clean up resources when exiting the context manager.

Raises:
    RuntimeError: If the context manager is already active.
ry   z is not active.NF)rQ   rz   r{   r<   ru   )r$   r   r   r   s   &&&&r   	__aexit__HttpClient.__aexit__   sJ      |||dnn&=&=%>oNOOlln 	s   A	AAA)rQ   rP   )r<   r=   r>   r?   r@   r   rR   rA   rV   rb   rm   rq   ru   r|   r   rB   r   r!   r   rI   rI   J   s5   _ -1     #'	
 (, )- %) 6  #	
 8< '+ #' (, %) >  #	
 8< '+ #' (, %) @  
 r!   rI   N)#
__future__r   abcr   r   dataclassesr   typingr   r   crawlee._utils.docsr	   collections.abcr
   
contextlibr   datetimer   typesr   crawleer   crawlee._typesr   r   r   crawlee.proxy_configurationr   crawlee.sessionsr   crawlee.statisticsr   r   rE   rI   r   r!   r   <module>r      s    " # ! * *-6"#CC5(- G#8 # #L $ 6 6 ! 6 NV V Vr!   