o
    +i.                     @  sR   d Z ddlmZ ddlZddlmZ ddlmZ dd
dZdddZ	dddZ
dS )ay  
This file includes code adapted from HTTPX's utility module
(https://github.com/encode/httpx/blob/336204f0121a9aefdebac5cacd81f912bafe8057/httpx/_utils.py).
We implement custom proxy handling to support configurations like `socket_options`,
which are not currently configurable through the HTTPX client.
For more context, see: https://github.com/encode/httpx/discussions/3514
    )annotationsN)Mapping)
getproxieshostnamestrreturnboolc                 C  0   zt | dd  W dS  ty   Y dS w N/r   FT)	ipaddressIPv4Addresssplit	Exceptionr    r   T/var/www/html/psymed-ai/venv/lib/python3.10/site-packages/anthropic/_utils/_httpx.pyis_ipv4_hostname      r   c                 C  r	   r
   )r   IPv6Addressr   r   r   r   r   r   is_ipv6_hostname   r   r   Mapping[str, str | None]c                  C  s   t  } i }dD ]}| |r"| | }d|v r|nd| || d< qdd | dddD }|D ]C}|d	kr=i   S |rvd|v rHd
||< q3t|rTd
|d| < q3t|rad
|d| d< q3| dkrod
|d| < q3d
|d| < q3|S )u   
    Gets the proxy mappings based on environment variables.
    We use our own logic to parse these variables, as HTTPX
    doesn’t allow full configuration of the underlying
    transport when proxies are set via environment variables.
    )httphttpsallz://zhttp://c                 S  s   g | ]}|  qS r   )strip).0hostr   r   r   
<listcomp>0   s    z+get_environment_proxies.<locals>.<listcomp>no ,*Nzall://zall://[]	localhostzall://*)r   getr   r   r   lower)
proxy_infomountsschemer   no_proxy_hostsr   r   r   get_environment_proxies    s.   
 
r+   )r   r   r   r   )r   r   )__doc__
__future__r   r   typingr   urllib.requestr   r   r   r+   r   r   r   r   <module>   s    

