Viewing File: /opt/imunify360/venv/lib/python3.11/site-packages/urllib3/__pycache__/connection.cpython-311.pyc



]jBIddlmZddlZddlZddlZddlZddlZddlZddlmZ	ddlm
Zddlm
Z
ddlmZddlmZdd	lmZ	ddlZejZn#eef$rdZGd
deZYnwxYw	eZn#e$rGdd
eZYnwxYw	eZn#e$rGddeZYnwxYwddlmZddl m!Z!ddl"m#Z#m$Z$m%Z%m&Z&ddl'm(Z(m)Z)ddl*m+Z+m,Z,m-Z-ddl.m/Z/m0Z0m1Z1m2Z2m3Z3ej4e5Z6dddZ7ej8dddZ9ej:dZ;Gddee<ZGddeZ=d Z>d!Z?Gd"d#e<Z@ese@Z=e=ZAdS)$)absolute_importN)error)timeout)six)HTTPConnection)
HTTPException)create_proxy_ssl_contextceZdZdS)BaseSSLErrorN__name__
__module____qualname__I/opt/imunify360/venv/lib64/python3.11/site-packages/urllib3/connection.pyrrrrceZdZdS)ConnectionErrorNr
rrrrr!rrrceZdZdS)BrokenPipeErrorNr
rrrrr*rrr)HTTPHeaderDict__version__)ConnectTimeoutErrorNewConnectionErrorSubjectAltNameWarningSystemTimeWarning)CertificateErrormatch_hostname)SKIP_HEADERSKIPPABLE_HEADERS
connection)assert_fingerprintcreate_urllib3_contextresolve_cert_reqsresolve_ssl_versionssl_wrap_socketPi)httphttpsiz[^-!#$%&'*+.^_`|~0-9a-zA-Z]ceZdZdZedZejejdfgZ	dZ
dZedZ
e
jdZ
dZd	Zd
ZdZdZd
Zdfd	ZddZxZS)ra5
    Based on :class:`http.client.HTTPConnection` but provides an extra constructor
    backwards-compatibility layer between older and newer Pythons.

    Additional keyword parameters are used to configure attributes of the connection.
    Accepted parameters include:

    - ``strict``: See the documentation on :class:`urllib3.connectionpool.HTTPConnectionPool`
    - ``source_address``: Set the source address for the current connection.
    - ``socket_options``: Set specific options on the underlying socket. If not specified, then
      defaults are loaded from ``HTTPConnection.default_socket_options`` which includes disabling
      Nagle's algorithm (sets TCP_NODELAY to 1) unless the connection is behind a proxy.

      For example, if you wish to enable TCP Keep Alive in addition to the defaults,
      you might pass:

      .. code-block:: python

         HTTPConnection.default_socket_options + [
             (socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1),
         ]

      Or you may want to disable the defaults by passing an empty list (e.g., ``[]``).
    r+rFcTtjs|dd|d|_|d|j|_|dd|_|dd|_tj
|g|Ri|dS)Nstrictsource_addresssocket_optionsproxyproxy_config)rPY2popgetr1default_socket_optionsr2r3r4_HTTPConnection__init__)selfargskws   rr:zHTTPConnection.__init__nsw	#FF8T"""!ff%566!ff%5t7RSSVVGT**
FF>488 333333333rc6|jdS)a
        Getter method to remove any trailing dots that indicate the hostname is an FQDN.

        In general, SSL certificates don't include the trailing dot indicating a
        fully-qualified domain name, and thus, they don't validate properly when
        checked against a domain name that includes the dot. In addition, some
        servers may not expect to receive the trailing dot when provided.

        However, the hostname with trailing dot is critical to DNS resolution; doing a
        lookup with the trailing dot will properly only resolve the appropriate FQDN,
        whereas a lookup without a trailing dot will search the system's search domain
        list. Thus, it's important to keep the original host around for use only in
        those cases where it's appropriate (i.e., when doing DNS lookup to establish the
        actual TCP connection across which we're going to send HTTP requests).
        .)	_dns_hostrstripr;s rhostzHTTPConnection.hosts"~$$S)))rc||_dS)z
        Setter for the `host` property.

        We assume that only urllib3 uses the _dns_host attribute; httplib itself
        only uses `host`, and it seems reasonable that other libraries follow suit.
        N)r@)r;values  rrCzHTTPConnection.hostsrc	8i}|jr
|j|d<|jr
|j|d<	tj|j|jf|jfi|}nO#t$r"t|d|j	d|jdt$r}t|d|zd}~wwxYw|S)zoEstablish a socket connection and set nodelay settings on it.

        :return: New socket connection.
        r1r2zConnection to z timed out. (connect timeout=)z(Failed to establish a new connection: %sN)r1r2r$create_connectionr@portr
SocketTimeoutrrCSocketErrorr)r;extra_kwconnes    r	_new_connzHTTPConnection._new_conns
	=)-)<H%&	=)-)<H%&	/+T\=EDD			%999dlll,
			$@1D
	
s$A4B?BBc$t|ddS)N_tunnel_host)getattrrBs r_is_using_tunnelzHTTPConnection._is_using_tunnelst^T222rcv||_|r|d|_dSdS)Nr)sockrS_tunnel	auto_openr;rMs  r
_prepare_connzHTTPConnection._prepare_conns?	  ""	LLNNNDNNN			rcX|}||dSN)rOrYrXs  rconnectzHTTPConnection.connects+~~4     rct|}|r(td|d|dt	j|||g|Ri|S) z+Method cannot contain non-token characters z (found at least rG)_CONTAINS_CONTROL_CHAR_REsearch
ValueErrorgroupr9
putrequest)r;methodurlr<kwargsmatchs      rrczHTTPConnection.putrequestst*0088	*665;;====*

)$MdMMMfMMMrc\td|Dstj||g|RdStj|tvrPtddttjttddS)r^c3VK|]$}t|to
|tkV%dSr[)
isinstancestrr").0vs  r	<genexpr>z+HTTPConnection.putheader.<locals>.<genexpr>s6KKq:a%%:!{*:KKKKKKrz(urllib3.util.SKIP_HEADER only supports 'z', ''N)
anyr9	putheaderr
ensure_strlowerr#rajoinmaprktitlesorted)r;headervaluess   rrqzHTTPConnection.putheadersKKFKKKKK	%dF<V<<<<<<
^FLLNN
+
+3D
D
D*;;s39f5F.G.GHHIIIIL
E
DrNc|i}n|}dd|Dvrt|d<tt|||||dS)N
user-agentc3bK|]*}tj|V+dSr[rrrrsrlks  rrnz)HTTPConnection.request.<locals>.<genexpr>s4KKaqwwyy 9 9KKKKKKr
User-Agent)bodyheaders)copy_get_default_user_agentsuperrrequest)r;rdrerr	__class__s     rrzHTTPConnection.requestsu?GGllnnGKK7KKKKK$;$=$=GL!
nd##++FCdG+TTTTTrc>|pi}td|D}d|v}d|v}|||||d|vr"|dt|D]\}}	|||	d|vr|dd	||tjtfz}
t||
r|f}|D]}|st|ts|
d}tt|dd
}t|
}
|
d
z
}
|
|z
}
|
d
z
}
||
|dd
S)z
        Alternative to the common request method, which sends the
        body with chunked encoding and not as one block
        cZg|](}tj|)Srr}r~s  r
<listcomp>z2HTTPConnection.request_chunked.<locals>.<listcomp>s*FFF3>!''))44FFFrzaccept-encodingrC)skip_accept_encoding	skip_hostr{rztransfer-encodingzTransfer-EncodingchunkedNutf8s
s0

)setrcrqritems
endheadersrstring_typesbytesrjencodehexlen	bytearraysend)r;rdrerrheader_keysrrrxrEstringish_typeschunklen_strto_sends              rrequest_chunkedzHTTPConnection.request_chunkeds
-RFFgFFFGG0K?k)	C.Bi		
	
	
{**NN<)@)B)BCCC$]]__	*	*MFENN65))))k11NN.	:::!.%9O$00
w

#

#!%//1!LL00Ec%jj//!""-#GNN$4$4557"5 7"		'""""	
		,r)NN)rrr__doc__port_by_schemedefault_portsocketIPPROTO_TCPTCP_NODELAYr8is_verifiedr:propertyrCsetterrOrSrYr\rcrqrr
__classcell__)rs@rrrKs02"&)L &163EqIJK444"**X*$
[[>333!!!NNNUUUUUU% % % % % % % % rrceZdZdZedZdZdZdZdZ	dZ
dZdZddddde
jddfdZ									d	dZdZdZdS)
HTTPSConnectionz
    Many of the parameters to this constructor are passed to the underlying SSL
    socket by means of :py:func:`urllib3.util.ssl_wrap_socket`.
    r,NFc
tj|||f||d|
||_||_||_||_|	|_d|_dS)N)r0rr,)rr:key_file	cert_filekey_passwordssl_contextserver_hostname	_protocol)r;rCrIrrrr0rrrr=s           rr:zHTTPSConnection.__init__$s\	dDWWWTVWWW 
"(&.!rc
J|#|j
|jj}ntd}||_||_||_||_||_||_|otj
||_|otj
||_
|	|_dS)zX
        This method should only be called once, before the connection is used.
        N)rverify_moder'rr	cert_reqsrassert_hostnamer%ospath
expanduserca_certsca_cert_dirca_cert_data)
r;rrrrrrr%rrs
          rset_certzHTTPSConnection.set_cert>s"+ ,8		-d33	 
""(."4 ARW%7%7%A%A
&J27+=+=k+J+J(rch|}|j}d}|rH|jr|||}d}||_|d|_|j}|}|j	|j	}tjtk}|r2tjdtt"d}|j<d}t't)|jt-|j|_|j}t-|j|_|js4|js-|js&|r$t9|dr|t=||j|j |j!|j|j|j|||

|_|rt|jmt9|jdrX|j"d	vr=tjd
|jd|j"dtF|j$r/tI|j%d
|j$n|jtLj'krtQ|dds||j)durs|j%}|*dds-tjd|tVtY||j)p||jtLj-kp|j$du|_.dS)NFTrzWSystem time is way off (before {0}). This will probably lead to SSL verification errors)ssl_versionrload_default_certs)
rUkeyfilecertfilerrrrrr
tls_in_tlsversion>TLSv1.1TLSv1zjNegotiating TLSv1/TLSv1.1 by default is deprecated and will be disabled in urllib3 v2.0.0. Connecting to 'z' with 'z;' can be enabled by explicitly opting-in with 'ssl_version')binary_formcheck_hostnamesubjectAltNamerzCertificate for {0} has no `subjectAltName`, falling back to check for a `commonName` for now. This feature is being removed by major browsers and deprecated by RFC 2818. (See https://github.com/urllib3/urllib3/issues/497 for details.))/rOrCrStls_in_tls_required_connect_tls_proxyrUrVrWrQrdatetimedatetodayRECENT_DATEwarningswarnformatrrr&r(rr'rrrrrhasattrrr)rrrrDeprecationWarningr%getpeercertssl	CERT_NONErRrr7r_match_hostname
CERT_REQUIREDr)	r;rMhostnamerris_time_offdefault_ssl_contextcontextcerts	         rr\zHTTPSConnection.connect_sr~~9
  ""	)'
"..x>>!
DI
LLNNNDN(H"+"2Om))++k9	M6&%%!


$#"&5/0@AA+DN;;   D
"/??

	)$	)%	)$		)
!566	)
&&(((#M^*](*+!


	"
 	 (	9--)	!!##';;;MM)-			493D3D3F3F3F3FH#


"	K	%%$%779P




3=00G%5u==
1$E11
9((**D88,b11	

()/x(8(8)
D$"6"I/JJJ
3#44
3&d2	
rc|j}|j}|rt|||St|j|j|j|j|j}d|_	t||j|j|j||S)zY
        Establish a TLS connection to the proxy using the provided SSL context.
        )rUrrT)rUrrrrr)
r4rr)r
rrrrrr)r;rrMr4rs     rrz"HTTPSConnection._connect_tls_proxys(".	# ('
/NM

&*"](*$#



	
r)	NNNNNNNNN)rrrrrrrrrrrr%rr_GLOBAL_DEFAULT_TIMEOUTr:rr\rrrrrrs
"'*LIHKLK
.!!!!8))))Bv
v
v
p$
$
$
$
$
rrc	t||dS#t$r)}td||||_d}~wwxYw)Nz@Certificate did not match expected hostname: %s. Certificate: %s)r!r logwarning
_peer_cert)rasserted_hostnamerNs   rrrsht./////			N	
	
	

	s
A$AAcdtzS)Nzpython-urllib3/%srrrrrr
s
,,rceZdZdZdS)DummyConnectionz-Used to detect a failed ConnectionCls import.N)rrrrrrrrrs77Drr)B
__future__rrloggingrrerrrrKrrJpackagesrpackages.six.moves.http_clientrr9r	
util.proxyr
rSSLErrorrImportErrorAttributeError
BaseExceptionr	NameError	Exceptionr_collectionsr_versionr
exceptionsrrrrpackages.ssl_match_hostnamer r!utilr"r#r$	util.ssl_r%r&r'r(r)	getLoggerrrrrrcompiler_objectrrrrVerifiedHTTPSConnectionrrr<module>rs&&&&&&								



''''''++++++MMMMMM999999000000
JJJ<LL^$


C




}






%OO







)






%OO







)





)(((((!!!!!!JIIIIIII<<<<<<<<<<g!!s++hmD!Q''&BJ'EFFF F F F F _fF F F Rg
g
g
g
g
ng
g
g
T---					f			&%O*s6AA*)A*.A11BBBB$#B$
Back to Directory File Manager