o
    î6Wj.  ã                   @  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   úf/home/esfera/Documents/content_generation/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    

