;i0PddlmZddlZddlZddlZddlZddlZddlZddl Z ddl Z ddl Z ddl Z ddlm ZddlmZddlmZddlmZe jrddlmZdd lmZdd lmZdd lmZdd lmZdd lm Z ddl!m"Z"m#Z#m$Z$ddl%m&Z&ddl'm(Z( ddl)Z)e)j*Z+n#e,e-f$rdZ)Gdde.Z+YnwxYwddl/m0Z0ddl/m1Z1ddl/m2Z2ddl3m4Z4ddl5m6Z6m7Z7m8Z8m9Z9m:Z:m;Z;ddlZ>m?Z?m@Z@ddlAmBZBddlmCZDddlmEZEmFZFmGZGmHZHmIZIddlJmKZKmLZLddlMmNZNeOZOePZPejQeRZSddd ZTejUd!ddZVejWd"ZXGd#d$eZ Gd%d&e ZYGd'd(e jZZ[d)d*dXdDZ\ dYdZdKZ]d[dPZ^d\dQZ_GdRdSZ`e)se`ZYeYZa d]d^dWZbdS)_) annotationsN)HTTPConnection) HTTPException)ResponseNotReadytimeout HTTPResponse)_TYPE_PEER_CERT_RET_DICT) SSLTransport)HTTPHeaderDict)probe)assert_header_parsing)_DEFAULT_TIMEOUT _TYPE_TIMEOUTTimeout)to_str) wait_for_readceZdZdS) BaseSSLErrorN)__name__ __module__ __qualname__FC:\PYTHON\MyICR_Workspace\venv\Lib\site-packages\urllib3/connection.pyrr%s rr) _TYPE_BODY) ProxyConfig)_ResponseOptions __version__)ConnectTimeoutErrorHeaderParsingErrorNameResolutionErrorNewConnectionError ProxyErrorSystemTimeWarning) SKIP_HEADERSKIPPABLE_HEADERS connectionssl_)body_to_chunks)assert_fingerprint)create_urllib3_context is_ipaddressresolve_cert_reqsresolve_ssl_versionssl_wrap_socket)CertificateErrormatch_hostname)UrlPihttphttpsiz[^-!#$%&'*+.^_`|~0-9a-zA-Z]ceZdZUdZedZded<ejej dfgZ ded<dZ d ed <d Z d ed <ded<ded<ded<d ed<ded<ded<ded<ded< dYe d de d d ddZfd*Zd[d+Zd[d,Zed[d-Zejd\d/Zd]d1Z d^d_fd5 Zejd6ksd7ejcxkrd8kr0nn-d`d;Zejd6krdad<Znd7ejcxkrd8krnndad=Zdad>Zedbd?Zedbd@ZedbdAZedbdBZedbdCZdafdD Z dcddfdI Z!defdL Z" dfddMdMdMdNdgdUZ# dfdhdVZ$difdX Z%xZ&S)jra 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: - ``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., ``[]``). r9ztyping.ClassVar[int] default_portr z0typing.ClassVar[connection._TYPE_SOCKET_OPTIONS]default_socket_optionsFbool is_verifiedNz bool | Noneproxy_is_verifiedint blocksizetuple[str, int] | Nonesource_addressz&connection._TYPE_SOCKET_OPTIONS | Nonesocket_options_has_connected_to_proxyz_ResponseOptions | None_response_options str | None _tunnel_host int | None _tunnel_port_tunnel_scheme@)rrDrBrEproxy proxy_confighoststrportrr&None | connection._TYPE_SOCKET_OPTIONSrN Url | NonerOProxyConfig | NonereturnNonect||tj|||||_||_||_d|_d|_d|_ d|_ d|_ dS)N)rPrRrrDrBF) super__init__rresolve_default_timeoutrErNrOrFrGrIrKrL) selfrPrRrrDrBrErNrO __class__s rrZzHTTPConnection.__init__s 3G<<)    - (',$!%(,(,*.rcPt|jd|jd|jdS)Nz(host=z, port=))typerrPrRr\s r__str__zHTTPConnection.__str__s.t**%OOTYOOOOOOrc0d|dt|ddS)N)idras r__repr__zHTTPConnection.__repr__s$+4++RXX+++++rc6|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_hostrstripras rrPzHTTPConnection.hosts"~$$S)))rvaluec||_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)rj)r\rls rrPzHTTPConnection.hostsr socket.socketc  tj|j|jf|j|j|j}n~#tj$r}t|j |||d}~wt$r'}t|d|j d|jd|d}~wt$r}t|d||d}~wwxYwtjd||j |j|S)zoEstablish a socket connection and set nodelay settings on it. :return: New socket connection. )rDrENzConnection to z timed out. (connect timeout=r_z&Failed to establish a new connection: zhttp.client.connect)r+create_connectionrjrRrrDrEsocketgaierrorr%rP SocketTimeoutr#OSErrorr&sysaudit)r\sockes r _new_connzHTTPConnection._new_conns   /+ #2#2 DD  A A A%diq99q @   %XXXXXX     $BqBB   'ty$)DDD s-36B1A B1)"B  B1B,,B1headerstyping.Mapping[str, str] | Noneschemec|dvrtd|dt|||||_dS)Nr8z$Invalid proxy scheme for tunneling: z", must be either 'http' or 'https')rRrz) ValueErrorrY set_tunnelrL)r\rPrRrzr|r]s rrzHTTPConnection.set_tunnels` * * *cvccc  4dG<<<$r) )r )rrripbytesc6d|vr|ddkrd|zdzS|S)N:r[[]r)r\rs r _wrap_ipv6zHTTPConnection._wrap_ipv6s-rzzbew..by4''Irc,tjj}d||jd|jfz}|g}|jD]3\}}| |d|dd4| d| d |~| |j |j} |\}}} |tjjkr;|t'd |d |  |j|d z} t/| |krtjd | sn3| dvrn.|jdkr"t5d| |dS#|wxYw)NsCONNECT %s:%d HTTP/1.0 ascii:  latin-1 rmethodTunnel connection failed:  Tr z header line)r rrheader:)r9client_MAXLINErrIencoderK_tunnel_headersitemsappendsendjoinresponse_classrw_method _read_status HTTPStatusOKclosertstripfpreadlinelen LineTooLong debuglevelprintdecode) r\rconnectrzheaderrlresponseversioncodemessagelines r_tunnelzHTTPConnection._tunnels;/7OOD$5$<$>F!)V]]__====t111 %QQQ QQ2NN$$$$$HNN$$$$s (CGGc||_|jrd|_|t |j|_|jr d|_dSdS)NTF)ryrwrIrFrr>rNr@ras rrzHTTPConnection.connectJslNN$$   +/D ( LLNNN (,DJ'7'7$  ' +%*D " " " + +rc|jduSN)rwras r is_closedzHTTPConnection.is_closed[syD  rcB|jdSt|jd S)NFgr)rwrras r is_connectedzHTTPConnection.is_connected_s' 9 5 C88888rc|jSr)rFras rhas_connected_to_proxyz%HTTPConnection.has_connected_to_proxyes ++rc<t|jo|jduS)zT Return True if a forwarding proxy is configured, else return False N)r>rNrIras rproxy_is_forwardingz"HTTPConnection.proxy_is_forwardingis! DJ=D$5$==rc|jduS)zS Return True if a tunneling proxy is configured, else return False N)rIras rproxy_is_tunnelingz!HTTPConnection.proxy_is_tunnelingps  ,,rc4 td|_d|_d|_d|_d|_d|_d|_d|_ dS#d|_d|_d|_d|_d|_d|_d|_d|_ wxYw)NF) rYrrwr?r@rFrGrIrKrL)r\r]s rrzHTTPConnection.closews ' GGMMOOODI$D %)D "+0D (%)D " $D  $D "&D   DI$D %)D "+0D (%)D " $D  $D "&D  & & & &s A:Brurl skip_hostskip_accept_encodingct|}|r(td|d|dt ||||S)z+Method cannot contain non-token characters z (found at least r_)rr)_CONTAINS_CONTROL_CHAR_REsearchr~grouprY putrequest)r\rrrrmatchr]s rrzHTTPConnection.putrequests*0088  kfkkY^YdYdYfYfkkk ww!! C9CW"   rrvaluescJtd|Dstj|g|RdSt|t vrDddtt D}td|ddS)rc3VK|]$}t|to |tkV%dSr) isinstancerQr)).0vs r z+HTTPConnection.putheader..s6KKq:a%%:!{*:KKKKKKrz', 'cBg|]}t|Sr)rQtitle)rrs r z,HTTPConnection.putheader..s$KKKv6""KKKrz(urllib3.util.SKIP_HEADER only supports ''N) anyrY putheaderrlowerr*rsortedr~)r\rrskippable_headersr]s rrzHTTPConnection.putheadersKKFKKKKK  EGG f .v . . . . . . FLLNN # #+< < < & KK8I1J1JKKK!! O;LOOO  = .s2CCaqwwyy 1 1CCCCCCrzaccept-encodingrP)rr)rrBztransfer-encodingzTransfer-Encodingrzcontent-lengthFTzContent-Lengthz user-agentz User-Agentzutf-8s%x %b s0 )rw settimeoutrr rG frozensetrr-rBchunkscontent_lengthrrQ_get_default_user_agentr endheadersrrrr)r\rrrrzrrrr header_keysrr chunks_and_clrrrrlchunks rrequestzHTTPConnection.requests 9 I  . . ."2!+)#9 " " "  ?GCC7CCCCC 0K?k)   C.Bi    'tFdnUUU %&5  J"+552I>>>  ;..$ 33 !))"&':IFFFNN#3S5H5HIII { * * NN<)@)B)B C C C$]]__ * *MFE NN65 ) ) ) )    % %eS))2!LL11E%IIoUU0CCDDDDIIe$$$$  $ IIl # # # # # $ $rcrtjdtd|||||ddS)z Alternative to the common request method, which sends the body with chunked encoding and not as one block zHTTPConnection.request_chunked() is deprecated and will be removed in urllib3 v2.1.0. Instead use HTTPConnection.request(..., chunked=True).category stacklevelT)rrzrN)warningswarnDeprecationWarningr)r\rrrrzs rrequest_chunkedzHTTPConnection.request_chunked sM   X'     VStWd KKKKKrr c|jt|j}d|_|j|jddlm}t|jdd}t } t|j nO#ttf$r;}tdt!||j|dYd}~nd}~wwxYwt%|j }||||j|jt|dd |j|j|j||j|j|j| }|S) a Get the response from the server. If the HTTPConnection is in the correct state, returns an instance of HTTPResponse or of whatever object is returned by the response_class variable. If a request has not been sent or if a previous response has not be handled, ResponseNotReady is raised. If the HTTP response indicates that the connection should be closed, then it will be closed before the response is returned. When the connection is closed, the underlying socket is closed. Nr r shutdownz$Failed to parse headers (url=%s): %sT)exc_info _http_vsn_strzHTTP/?) rrzstatusrversion_stringreasonrroriginal_responserrr sock_shutdown)rGrrwrrrr getattrrY getresponsermsgr$ TypeErrorlogwarning_url_from_connectionrrrrrrrrrr) r\ resp_optionsr _shutdownhttplib_responsehperzrr]s rr zHTTPConnection.getresponses  ! )"$$ $- !% T\*** +***** DIz488 !77..00  !"2"6 7 7 7 7"I.    KK6$T<+CDD          !!1!5!;!;!=!=>><!#*$,"4(CC#*(8'6.#/#F'6$0#   sBC"'1CC"r)rPrQrRrJrrrDrCrBrArErSrNrTrOrUrVrWrVrQ)rlrQrVrW)rVrn)NNr9) rPrQrRrJrzr{r|rQrVrW)rrrVrrVrW)rVr>)FF) rrQrrQrr>rr>rVrW)rrQrrQrVrW)NN)rrQrrQrrrzr{rr>rr>rr>rr>rVrW) rrQrrQrrrzr{rVrW)rVr )'rrr__doc__port_by_schemer<__annotations__rq IPPROTO_TCP TCP_NODELAYr=r?r@rrZrbrgpropertyrPsetterryrru version_inforrrrrrrrrrrrrr  __classcell__r]s@rrrRs=0*8)?L????  V/3P K&*))))NNN****::::!!!!....  / "215 # +/////////>PPPP,,,,***X*$ [[@ 37 % % % % % % % *$$C4D)Q)Q)Q)Qz)Q)Q)Q)Q)Q      j ( (& %& %& %& %& %P( 5 5 5 5: 5 5 5 5 5 % % % %D++++"!!!X!999X9 ,,,X,>>>X> ---X- ' ' ' ' ' '& %*        (      $#'37 _$ $#'+_$_$_$_$_$_$J#'37 LLLLL&<<<<<<<<<<rrceZdZUdZedZdZded<dZded<dZ ded<dZ d ed <dZ ded <dZ d ed <dZ d ed<dZded<dZded< d5eddejdddddddddddddddddd6fd-Z d7d8d.Zd9d/Zd:d4ZxZS);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:Nint | str | None cert_reqsrHca_certs ca_cert_dirNone | str | bytes ca_cert_data ssl_versionrJssl_minimum_versionssl_maximum_versionr.z!typing.Callable[..., None] | None_connect_callbackrM)rrDrBrErNrOr"assert_hostnamer.server_hostname ssl_contextr#r$r&r(r)r' cert_filekey_file key_passwordrPrQrRrrrDrCrBrArErSrNrTrOrUr+"None | str | typing.Literal[False]r,r-ssl.SSLContext | Noner.r/r0rVrWc t||||||||||_||_||_| |_| |_| |_| |_||_ ||_ ||_ |otj ||_|otj ||_||_| #|j |jj} nt'd} | |_d|_dS)N)rRrrDrBrErNrO)rYrZr/r.r0r-r,r+r.r'r(r)ospath expanduserr#r$r& verify_moder1r"r*)r\rPrRrrDrBrErNrOr"r+r.r,r-r#r$r&r(r)r'r.r/r0r]s rrZzHTTPSConnection.__init__ms8  ))%  ! "(&.."4&#6 #6  ARW%7%7%A%A &J27+=+=k+J+J(  + ,8 -d33 "!%rc tjdtd|#|j |jj}nt d}||_||_||_||_ ||_ ||_ |otj ||_|otj ||_| |_dS)zX This method should only be called once, before the connection is used. zHTTPSConnection.set_cert() is deprecated and will be removed in urllib3 v2.1.0. Instead provide the parameters to the HTTPSConnection constructor.rrN)rrrr-r7r1r/r.r"r0r+r.r4r5r6r#r$r&) r\r/r.r"r0r#r+r.r$r&s rset_certzHTTPSConnection.set_certs   +(       + ,8 -d33   ""(."4 ARW%7%7%A%A &J27+=+=k+J+J(rc|j|j|j}|j}n|j}|j}dtjvrt j||}nd}|j)|dtj | | x|_ }|j}d}|j r||jdkr%||j|x|_ }d}n|jdkrd|_d|_|t'jt*|j}|j|j}t.jt4k}|r#t7jd t4d t:|d }t?did |d |j d|j!d|j"d|j#d|j$d|j%d|j&d|j'd|j(d|j)d|d|j*d|d|j+d|j,} | j-|_ nX#t\$rK|j)|dtj ||t j/||dwxYw|4| j-0dk} t j/||| |j1rd|_2n | j2|_2tg|j4|_|jr|j| j2|_dSdSdS)Nh2)rPrRFzbefore connect) thread_idtarget_supports_http2r:Tr9zSystem time is way off (before z5). This will probably lead to SSL verification errorsrirwr"r'r(r)r#r$r&r.r/r0r,r- tls_in_tlsr+r.zafter connect failure)rPrRsupports_http2r)5rIrKrPrRr,ALPN_PROTOCOLS http2_probeacquire_and_getr* threading get_identryrwrrL_connect_tls_proxyr@rFrtypingcastrQr,datetimedatetoday RECENT_DATErrr(rk#_ssl_wrap_socket_and_match_hostnamer"r'r(r)r#r$r&r.r/r0r-r+r.rq BaseExceptionset_and_releaseselected_alpn_protocolrr?r>rN) r\probe_http2_hostprobe_http2_portr=rwr,r> is_time_offserver_hostname_rm_dotsock_and_verifiedr?s rrzHTTPSConnection.connects   (T->-J#0 #0  #y #y  4& & &$/$?%,<%%% ! ! %* !  ! -  " " #-//&; #    I #~~// /DI#'9OJ& F&'11'+'>'>ty$'O'OODI!%JJ(F22-2D*04, "(+c43D"E"E#/"&"6"---//+=K  :+:::& &5%;%;C%@%@ " C!!!T!..!!,,!%)$<$< ! %)$<$< !  !!,,!"..!..!!"..!!7 6!!,,!&:!!% 4 4! $(#:#:!! $*0DII   %1&&+'133*?' %,+)0@QU   ! (.5LLNNRVVN  '%%-      # =$D  0)rFrGrrOr-rLr"r'r(r)r#r$r&r+r.r?r@rq)r\rUrwrOr-rTs rrEz"HTTPSConnection._connect_tls_proxy]s {;0ABB ". ?  n( $ 8 $ 8](*$#(8+>#   &"3!> ''rr).rPrQrRrJrrrDrCrBrArErSrNrTrOrUr"r!r+r1r.rHr,rHr-r2r#rHr$rHr&r%r(rJr)rJr'r!r.rHr/rHr0rHrVrW) NNNNNNNNN)r/rHr.rHr"r!r0rHr#rHr+r1r.rHr$rHr&r%rVrWr)rUrQrwrnrVrV)rrrrrr<r"rr#r$r&r'r(r)r.r*rrr=rZr9rrErrs@rr r [s "'*L"&I&&&&H"K""""'+L++++$(K((((&*****&*****%)))));?????  <& "215  1 +/&*>B)-&*-1#"&+/*.*.(, $##'5<&<&<&<&<&<&<&<&@ $ $&*#'#>B)-"&+/')')')')')RGCGCGCGCR((((((((rr c(eZdZUdZded<ded<dS)_WrappedAndVerifiedSocketz[ Wrapped socket and whether the connection is verified after the TLS handshake zssl.SSLSocket | SSLTransportrqr>r?N)rrrrrrrrrYrY{s6 )(((rrYF)r>rwrnr"None | str | intr'r(rJr)r.rHr/r0r#r$r&r%r+r1r.r,r-r2r>r>rVc d}|0d}tt|||t|}n|}t||_| s| s| dustjs tjsd|_|s*| s(| s&|r$t|dr| | G| d}d|vr|d| d}t|r|} t|||||| | | || } | r%t|d | n_|jt jkrJ|jsC| dur?|}|rd}nt%|d dpd}t'|| p| |t)||jt jkpt-|  S#t.$r|wxYw) a2Logic for constructing an SSLContext from all TLS parameters, passing that down into ssl_wrap_socket, and then doing certificate verification either via hostname or fingerprint. This function exists to guarantee that both proxies and targets have the same behavior when connecting via TLS. FNT)r'r(r)r"load_default_certs[]%) rwkeyfilecertfiler0r#r$r&r,r-r>) binary_formhostname_checks_common_name)rqr?)r/r2r1r7r, IS_PYOPENSSLHAS_NEVER_CHECK_COMMON_NAMEcheck_hostnamehasattrr\rrfindr0r3_assert_fingerprint getpeercertssl CERT_NONEr_match_hostnamerY CERT_REQUIREDr>rMr)rwr"r'r(r)r.r/r0r#r$r&r+r.r,r-r>default_ssl_contextcontext normalizedssl_sockcertrbs rrLrLs0 "(+K88 3 3' 22    +I66G  '  ' e # #   $/ $ "' %%% % G1 2 2 % ""$$$ "$**400 *  #$;j&6&6s&;&;$;>3C3C D DEE"22 6 !1 1 6 !%5 5  (  \!5 Y,':Q:Q  WY \ \ G G NrcdtS)Nzpython-urllib3/r!rrrrr5s *[ * **rceZdZdZdS)DummyConnectionz-Used to detect a failed ConnectionCls import.N)rrrrrrrrr9s7777rrconn HTTPConnection | HTTPSConnectionr5cxt|trdnd}t||j|j|jS)zUReturns the URL from a given connection. This is mainly used for testing and logging.r:r9)r|rPrRr5)rr r6rPrRr)rr5r|s rrrDs: #499 EWWvF f49494 H H H LLr)"rwrnr"rZr'rZr(rJr)rJr.rHr/rHr0rHr#rHr$rHr&r%r+r1r.rHr,rHr-r2r>r>rVrY)F)rrrsrtrQrbr>rVrW)rxryrzrHrVr'rr)rrr5rHrVrQ)c __future__rrH http.clientr9loggingr4r|rqrurCrFrr_HTTPConnectionrrrrs TYPE_CHECKINGrr util.ssl_r util.ssltransportr _collectionsrhttp2rrA util.responser util.timeoutrrr util.utilr util.waitrrjSSLErrorr ImportErrorAttributeErrorrM_base_connectionrrr _versionr" exceptionsr#r$r%r&r'r(utilr)r*r+r, util.requestr-r.rhr/r0r1r2r3util.ssl_match_hostnamer4r5util.urlr6ConnectionErrorBrokenPipeError getLoggerrr rrIrKcompilerr  NamedTuplerYrLrlrrrVerifiedHTTPSConnectionrrrrrs """"""  999999666666((((((++++++ 0&&&&&&333333//////((((((''''''000000BBBBBBBBBB$$$$$$ JJJ