Viewing File: /opt/alt/python38/lib/python3.8/site-packages/urllib3/util/__pycache__/ssltransport.cpython-38.pyc

U

`@sFddlZddlZddlZddlmZddlmZdZGdddZdS)N)ProxySchemeUnsupported)sixi@c@seZdZdZeddZd:ddZdd	Zd
dZdd
Z	d;ddZ
d<ddZd=ddZd>ddZ
d?ddZd@ddZddZdd ZdAd"d#Zd$d%Zd&d'Zd(d)Zd*d+Zd,d-Zd.d/Zd0d1Zd2d3Zd4d5ZdBd6d7Zd8d9ZdS)CSSLTransportaL
    The SSLTransport wraps an existing socket and establishes an SSL connection.

    Contrary to Python's implementation of SSLSocket, it allows you to chain
    multiple TLS connections together. It's particularly useful if you need to
    implement TLS within TLS.

    The class supports most of the socket API operations.
    cCs&t|ds"tjrtdntddS)z
        Raises a ProxySchemeUnsupported if the provided ssl_context can't be used
        for TLS in TLS.

        The only requirement is that the ssl_context provides the 'wrap_bio'
        methods.
        wrap_biozKTLS in TLS requires SSLContext.wrap_bio() which isn't supported on Python 2zXTLS in TLS requires SSLContext.wrap_bio() which isn't available on non-native SSLContextN)hasattrrZPY2r)ssl_contextrJ/opt/alt/python38/lib/python3.8/site-packages/urllib3/util/ssltransport.py$_validate_ssl_context_for_tls_in_tlss

z1SSLTransport._validate_ssl_context_for_tls_in_tlsNTcCsHt|_t|_||_||_|j|j|j|d|_||jj	dS)zV
        Create an SSLTransport around socket using the provided ssl_context.
        )server_hostnameN)
sslZ	MemoryBIOincomingoutgoingsuppress_ragged_eofssocketrsslobj_ssl_io_loopZdo_handshake)selfrrrrrrr	__init__,s

zSSLTransport.__init__cCs|SNrrrrr		__enter__?szSSLTransport.__enter__cGs|dSr)close)r_rrr	__exit__BszSSLTransport.__exit__cCs
|jSr)rfilenorrrr	rEszSSLTransport.filenocCs|||Sr)_wrap_ssl_read)rlenbufferrrr	readHszSSLTransport.readrcCs|dkrtd||S)Nrz+non-zero flags not allowed in calls to recv)
ValueErrorr)rrflagsrrr	recvKszSSLTransport.recvcCs>|dkrtd|r&|dkr&t|}n|dkr2d}|||S)Nrz0non-zero flags not allowed in calls to recv_intor)r!rr )rrnbytesr"rrr		recv_intoPs
zSSLTransport.recv_intoc
Csn|dkrtdd}t|H}|d2}t|}||krV|||d}||7}q2W5QRXW5QRXdS)Nrz.non-zero flags not allowed in calls to sendallB)r!
memoryviewcastrsend)rdatar"countZviewZ	byte_viewZamountvrrr	sendallYszSSLTransport.sendallcCs$|dkrtd||jj|}|S)Nrz+non-zero flags not allowed in calls to send)r!rrwrite)rr*r"Zresponserrr	r)cszSSLTransport.sendrc
Cst|dddhks td|fd|k}d|kp4|}|sB|sBtd|k}d}	|rZ|	d7}	|rf|	d7}	t||	}
|jjd7_|dkrd}|d	krtj}|d	kr|std
|
S|r|rt|
|
|}n&|rt	|
|}n|stt
|
|}|r|St||||}||_|S)a
        Python's httpclient uses makefile and buffered io when reading HTTP
        messages and we need to support it.

        This is unfortunately a copy and paste of socket.py makefile with small
        changes to point to the socket directly.
        r/wbz&invalid mode %r (only r, w, b allowed)Nrz!unbuffered streams must be binary)
setr!AssertionErrorrZSocketIOZ_io_refsioDEFAULT_BUFFER_SIZEBufferedRWPairBufferedReaderBufferedWriter
TextIOWrappermode)
rr=	bufferingencodingerrorsnewlineZwritingZreadingZbinaryZrawmoderawrtextrrr	makefileis@
zSSLTransport.makefilecCs||jjdSr)rrunwraprrrr	rEszSSLTransport.unwrapcCs|jdSr)rrrrrr	rszSSLTransport.closeFcCs|j|Sr)rgetpeercert)rZbinary_formrrr	rFszSSLTransport.getpeercertcCs
|jSr)rversionrrrr	rGszSSLTransport.versioncCs
|jSr)rcipherrrrr	rHszSSLTransport.ciphercCs
|jSr)rselected_alpn_protocolrrrr	rIsz#SSLTransport.selected_alpn_protocolcCs
|jSr)rselected_npn_protocolrrrr	rJsz"SSLTransport.selected_npn_protocolcCs
|jSr)rshared_ciphersrrrr	rKszSSLTransport.shared_cipherscCs
|jSr)rcompressionrrrr	rLszSSLTransport.compressioncCs|j|dSr)r
settimeout)rvaluerrr	rMszSSLTransport.settimeoutcCs
|jSr)r
gettimeoutrrrr	rOszSSLTransport.gettimeoutcCs|jdSr)r_decref_socketiosrrrr	rPszSSLTransport._decref_socketiosc
Cs\z||jj||WStjk
rV}z"|jtjkrD|jrDWY
dSW5d}~XYnXdS)Nr)rrr rSSLErrorerrnoZ
SSL_ERROR_EOFr)rrrerrr	rs
zSSLTransport._wrap_ssl_readc
Gsd}d}|rd}z||}Wn@tjk
r\}z |jtjtjfkrF||j}W5d}~XYnX|j}|j||dkrd}q|tjkr|j	t
}|r|j|q|j
q|S)z>Performs an I/O loop between incoming/outgoing and the socket.TNF)rrQrRZSSL_ERROR_WANT_READZSSL_ERROR_WANT_WRITErr rr-r#
SSL_BLOCKSIZEr
r.Z	write_eof)rfuncargsZshould_loopZretrRrSZbufrrr	rs(

zSSLTransport._ssl_io_loop)NT)rN)rr)Nr)r)r)r/NNNN)F)N)__name__
__module____qualname____doc__staticmethodr
rrrrr r#r%r-r)rDrErrFrGrHrIrJrKrLrMrOrPrrrrrr	rsD





	



-

	r)	r7rrZurllib3.exceptionsrZurllib3.packagesrrTrrrrr	<module>s
Back to Directory File Manager