
    6j
                         d Z ddlZddlmZ ddlZddlmZmZ  ej        e	          Z
 G d d          Z G d d	          ZdS )
HTTP client.    N)Any   )DDGSExceptionTimeoutExceptionc                   z    e Zd ZdZdZdeddfdZedefd            Z	edefd            Z
edefd	            ZdS )
ResponsezHTTP response.)_respcontentstatus_codetextrespreturnNc                 \    || _         |j        | _        |j        | _        |j        | _        d S )N)r
   r   r   r   )selfr   s     R/root/.hermes/hermes-agent/venv/lib64/python3.11/site-packages/ddgs/http_client.py__init__zResponse.__init__   s*    
+|I			    c                     | j         j        S )z#Get response body as Markdown text.)r
   text_markdownr   s    r   r   zResponse.text_markdown   s     z''r   c                     | j         j        S )z Get response body as plain text.)r
   
text_plainr   s    r   r   zResponse.text_plain   s     z$$r   c                     | j         j        S )zGet response body as rich text.)r
   	text_richr   s    r   r   zResponse.text_rich"   s     z##r   )__name__
__module____qualname____doc__	__slots__r   r   propertystrr   r   r    r   r   r	   r	      s        ;IS T     (s ( ( ( X( %C % % % X% $3 $ $ $ X$ $ $r   r	   c            
           e Zd ZdZddddedz  dedz  deez  d	dfd
Zdeded	e	fdZ
dededed	e	fdZdededed	e	fdZdS )
HttpClientr   N
   T)verifyproxytimeoutr'   r   c                    t          j        ||ddt          |t                    r|ndt          |t                    r|nd          | _        dS )a  Initialize the HttpClient object.

        Args:
            proxy (str, optional): proxy for the HTTP client, supports http/https/socks5 protocols.
                example: "http://user:pass@example.com:3128". Defaults to None.
            timeout (int, optional): Timeout value for the HTTP client. Defaults to 10.
            verify: (bool | str):  True to verify, False to skip, or a str path to a PEM file. Defaults to True.

        randomTN)r(   r)   impersonateimpersonate_osr'   ca_cert_file)primpClient
isinstanceboolr"   client)r   r(   r)   r'   s       r   r   zHttpClient.__init__+   sX     l #'55?664#-fc#:#:D
 
 
r   argskwargsc                     	  | j         j        |i |}t          |          S # t          j        $ r}t          |          |d}~wt          $ r.}t          |          j         d|}t          |          |d}~ww xY w)z"Make a request to the HTTP client.Nz: )
r3   requestr	   r/   TimeoutErrorr   	Exceptiontyper   r   )r   r4   r5   r   exmsgs         r   r7   zHttpClient.request>   s    	-&4;&777DD>>!! 	/ 	/ 	/"2&&B. 	- 	- 	-"XX&00"00C$$",	-s     # A=AA=)A88A=urlc                 &     | j         d|g|R i |S )z&Make a GET request to the HTTP client.GETr7   r   r=   r4   r5   s       r   getzHttpClient.getI   s&    t|E38888888r   c                 &     | j         d|g|R i |S )z'Make a POST request to the HTTP client.POSTr@   rA   s       r   postzHttpClient.postM   s&    t|FC9$999&999r   )Nr&   )r   r   r   r   r"   intr2   r   r   r	   r7   rB   rE   r#   r   r   r%   r%   (   s        
cg 
 
 
cDj 
#* 
VZ]`V` 
lp 
 
 
 
&	-S 	-C 	-H 	- 	- 	- 	-9s 93 9# 9( 9 9 9 9: :C :3 :8 : : : : : :r   r%   )r   loggingtypingr   r/   
exceptionsr   r   	getLoggerr   loggerr	   r%   r#   r   r   <module>rL      s              7 7 7 7 7 7 7 7		8	$	$$ $ $ $ $ $ $ $6': ': ': ': ': ': ': ': ': ':r   