o
    i                     @   s   d dl Z d dlZd dlmZ d dlmZ d dlmZ d dlmZ d dl	m
Z
 d dlmZ d dlmZ d d	lmZ G d
d deZefdededefddZdS )    N)Optional)urlparse)HTTPConnection)HTTPSConnection)UDSHTTPConnection)DEFAULT_TIMEOUT)ConnectionType)
verify_urlc                	       s@   e Zd ZdZ	d	dedee deej ddf fddZ	  Z
S )
ProxiedHTTPSConnectionz
    The built-in http.client in Python doesn't respect HTTPS_PROXY (even tho other clients like requests and curl do).

    This implementation simply extends the client with support for basic proxies.
    Nhostportcontextreturnc           	         st   dt jv r-|pd}tt jd }|jpd}|jpd}t j||fi | | || d S t j||fi | d S )NHTTPS_PROXYi   i8  )osenvironr   hostnamer   super__init__
set_tunnel)	selfr   r   r   kwargstunnel_portproxy
proxy_host
proxy_port	__class__ H/home/ubuntu/.local/lib/python3.10/site-packages/ddtrace/llmobs/_http.pyr      s   


zProxiedHTTPSConnection.__init__)NN)__name__
__module____qualname____doc__strr   intssl
SSLContextr   __classcell__r   r   r   r    r
      s    r
   urltimeoutr   c                 C   s   t | }|jpd}|jpd}|jdkrtj||j||dS |jdkr,tj||j||dS |jdkr:t|||j|dS t	d|j )	z+Return an HTTP connection to the given URL.r   /https)	base_pathr+   httpunix)r+   zUnsupported protocol '%s')
r	   r   pathschemer
   with_base_pathr   r   r   
ValueError)r*   r+   parsedr   r1   r   r   r    get_connection$   s   




r6   )r   r'   typingr   urllib.parser   ddtrace.internal.httpr   r   ddtrace.internal.udsr   ddtrace.internal.utils.httpr   r   r	   r
   r%   floatr6   r   r   r   r    <module>   s    