o
    'hC"                     @  s0  U d dl mZ 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
mZmZ ddlmZ dd	lmZ dd
lmZ ddlmZmZ ddlmZ ddlmZmZmZmZ ddlmZ ddlmZm Z  ej!rpddlm"Z"m#Z# G dd dZ$G dd de$Z%ej!re$dd Z&de'd< e%dd Z(de'd< dS dS )    )annotationsN)HTTPException)ResponseNotReady   )
_TYPE_BODY)HTTPConnectionProxyConfigport_by_scheme)TimeoutError)BaseHTTPResponse)_TYPE_SOCKET_OPTIONS)_DEFAULT_TIMEOUT_TYPE_TIMEOUT)Url   )_RequestError_TimeoutErrorsend_requestsend_streaming_request)EmscriptenRequest)EmscriptenHttpResponseWrapperEmscriptenResponse)BaseHTTPConnectionBaseHTTPSConnectionc                   @  s  e Zd ZU ed Zded< ded< ded< ded	< d
ed< d
ed< ded< ded< ded< ded< dZded< dZded< ded< 	dDedddddddEd#d$Z				dFdGd)d*Z
dHd+d,Z		dIdd-d-d-d.dJd7d8ZdKd:d;ZdHd<d=ZedLd>d?ZedLd@dAZedLdBdCZdS )MEmscriptenHTTPConnectionhttpztyping.ClassVar[int]default_portz%typing.ClassVar[_TYPE_SOCKET_OPTIONS]default_socket_optionszNone | floattimeoutstrhostintport	blocksizetuple[str, int] | Nonesource_address_TYPE_SOCKET_OPTIONS | Nonesocket_options
Url | NoneproxyProxyConfig | Noneproxy_configFboolis_verifiedNzbool | Noneproxy_is_verifiedzEmscriptenResponse | None	_responser   i    )r   r%   r#   r'   r)   r+   r   returnNonec          	      C  sZ   || _ || _t|tr|nd| _d| _d| _d | _d | _d | _	|| _
d | _d | _d| _d S )Ng        r   TF)r    r"   
isinstancefloatr   scheme_closedr/   r)   r+   r#   r%   r'   r-   )	selfr    r"   r   r%   r#   r'   r)   r+    r7   a/var/www/html/olx_land/venv/lib/python3.10/site-packages/urllib3/contrib/emscripten/connection.py__init__-   s   
z!EmscriptenHTTPConnection.__init__
int | Noneheaderstyping.Mapping[str, str] | Noner4   c                 C     d S Nr7   )r6   r    r"   r;   r4   r7   r7   r8   
set_tunnelH   s   z#EmscriptenHTTPConnection.set_tunnelc                 C  r=   r>   r7   r6   r7   r7   r8   connectQ   s   z EmscriptenHTTPConnection.connectT)chunkedpreload_contentdecode_contentenforce_content_lengthmethodurlbody_TYPE_BODY | NonerB   rC   rD   rE   c             
   C  s   d| _ |dr| j d| j d| j | }t||| jr | jnd|d}	|	| |r;| D ]
\}
}|		|
| q0d | _
z|sFt|	| _
| j
d u rSt|	| _
W d S W d S  tyg } zt|j|d }~w tyx } zt|j|d }~ww )NF/z://:r   )rG   rF   r   rD   )r5   
startswithr4   r    r"   r   r   set_bodyitems
set_headerr/   r   r   r   r
   messager   r   )r6   rF   rG   rH   r;   rB   rC   rD   rE   requestkver7   r7   r8   rQ   T   s6   



z EmscriptenHTTPConnection.requestr   c                 C  s&   | j d urt| j | j jj| dS t )N)internal_responserG   
connection)r/   r   rQ   rG   r   r@   r7   r7   r8   getresponse|   s   
z$EmscriptenHTTPConnection.getresponsec                 C  s   d| _ d | _d S )NT)r5   r/   r@   r7   r7   r8   close   s   
zEmscriptenHTTPConnection.closec                 C  s   | j S )zWhether the connection either is brand new or has been previously closed.
        If this property is True then both ``is_connected`` and ``has_connected_to_proxy``
        properties must be False.
        )r5   r@   r7   r7   r8   	is_closed   s   z"EmscriptenHTTPConnection.is_closedc                 C     dS )zLWhether the connection is actively connected to any origin (proxy or target)Tr7   r@   r7   r7   r8   is_connected   s   z%EmscriptenHTTPConnection.is_connectedc                 C  rZ   )zWhether the connection has successfully connected to its proxy.
        This returns False if no proxy is in use. Used to determine whether
        errors are coming from the proxy layer or from tunnelling to the target origin.
        Fr7   r@   r7   r7   r8   has_connected_to_proxy   s   z/EmscriptenHTTPConnection.has_connected_to_proxyr   )r    r   r"   r!   r   r   r%   r$   r#   r!   r'   r&   r)   r(   r+   r*   r0   r1   )r   Nr   )
r    r   r"   r:   r;   r<   r4   r   r0   r1   )r0   r1   )NN)rF   r   rG   r   rH   rI   r;   r<   rB   r,   rC   r,   rD   r,   rE   r,   r0   r1   )r0   r   )r0   r,   )__name__
__module____qualname__r	   r   __annotations__r-   r.   r   r9   r?   rA   rQ   rW   rX   propertyrY   r[   r\   r7   r7   r7   r8   r      sX   
 
	

(

r   c                      s   e Zd ZU ed ZdZded< dZded< dZded< dZ	ded	< ded
< ded< ded< ded< dZ
ded< dZded< dZded< ded< dZded< 	d/eddejdddddddddddddddddd0 fd+d,Z									d1d2d-d.Z  ZS )3EmscriptenHTTPSConnectionhttpsNint | str | None	cert_reqs
str | Noneca_certsca_cert_dirNone | str | bytesca_cert_data	cert_filekey_filekey_passwordtyping.Any | Nonessl_contextssl_versionr:   ssl_minimum_versionssl_maximum_version"None | str | typing.Literal[False]assert_hostnameassert_fingerprintr   i @  )r   r%   r#   r'   r)   r+   rf   ru   rv   server_hostnamerp   rh   ri   rk   rr   rs   rq   rl   rm   rn   r    r   r"   r!   r   r   r%   r$   r#   r'   None | _TYPE_SOCKET_OPTIONSr)   r(   r+   r*   rw   r0   r1   c             
     s   t  j||||||||d d| _|| _|| _|| _|| _|| _|
| _|| _	|| _
|| _|| _|o6tj|| _|o?tj|| _|| _d | _d| _d S )N)r"   r   r%   r#   r'   r)   r+   rd   T)superr9   r4   rm   rl   rn   rp   rw   ru   rv   rq   rr   rs   ospath
expanduserrh   ri   rk   rf   r-   )r6   r    r"   r   r%   r#   r'   r)   r+   rf   ru   rv   rw   rp   rh   ri   rk   rr   rs   rq   rl   rm   rn   	__class__r7   r8   r9      s4   

z"EmscriptenHTTPSConnection.__init__c
           
      C  r=   r>   r7   )
r6   rm   rl   rf   rn   rh   ru   rv   ri   rk   r7   r7   r8   set_cert   s   z"EmscriptenHTTPSConnection.set_certr]   ).r    r   r"   r!   r   r   r%   r$   r#   r!   r'   rx   r)   r(   r+   r*   rf   re   ru   rt   rv   rg   rw   rg   rp   ro   rh   rg   ri   rg   rk   rj   rr   r:   rs   r:   rq   re   rl   rg   rm   rg   rn   rg   r0   r1   )	NNNNNNNNN)rm   rg   rl   rg   rf   re   rn   rg   rh   rg   ru   rt   rv   rg   ri   rg   rk   rj   r0   r1   )r^   r_   r`   r	   r   rf   ra   rh   ri   rk   rq   rr   rs   rv   r   r   r   r9   r   __classcell__r7   r7   r}   r8   rc      s`   
 >rc    r   _supports_http_protocolr   _supports_https_protocol))
__future__r   rz   typinghttp.clientr   r   _base_connectionr   rV   r   r   r	   
exceptionsr
   responser   util.connectionr   util.timeoutr   r   util.urlr   fetchr   r   r   r   rQ   r   r   r   TYPE_CHECKINGr   r   r   rc   r   ra   r   r7   r7   r7   r8   <module>   s0     ]