{fTddlmZddlZddlZddlZddlZddlZddlZddl Z ddl Z ddl Z ddl Z ddlm ZddlmZddlmZddlmZe j&rddlmZdd lmZdd lmZdd lmZdd lmZdd lm Z ddl!m"Z"m#Z#m$Z$ddl%m&Z&ddl'm(Z( ddl)Z)e)jTZ+ddl/m0Z0ddl/m1Z1ddl/m2Z2ddl3m4Z4ddl5m6Z6m7Z7m8Z8m9Z9m:Z:m;Z;ddlZ>m?Z?m@Z@ddlAmBZBddlmCZDddlmEZEmFZFmGZGmHZHmIZIddlJmKZKmLZLddlMmNZNeOZOePZPejeRZSddd ZTejd!d"dZVejd#ZXeYe d$ZZGd%d&eZ Gd'd(e Z[Gd)d*e jZ]d+d, d4d-Z^ d5 d6d.Z_d7d/Z`d8d0ZaGd1d2Zbe)sebZ[e[Zc d9 d:d3Zdy#e,e-f$rdZ)Gdde.Z+YAwxYw);) annotationsN)HTTPConnection) HTTPException)ResponseNotReadytimeout HTTPResponse)_TYPE_PEER_CERT_RET_DICT) SSLTransport)HTTPHeaderDict)probe)assert_header_parsing)_DEFAULT_TIMEOUT _TYPE_TIMEOUTTimeout)to_str) wait_for_readc eZdZy) BaseSSLErrorN)__name__ __module__ __qualname__[/var/lib/jenkins/workspace/mettalog/venv/lib/python3.12/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]auditceZdZUdZedZded<ejejdfgZ ded<dZ d ed <d Z d ed <ded<ded<ded<d ed<ded<ded<ded<ded< d2e d de d d d d3fdZed4dZej"d5d Zd6d!Z d7 d8fd" Zej*d#krd9d$Zd9d%Zed:d&Zed:d'Zed:d(Zed:d)Zd9fd* Z d; d<fd+ Zd=fd, Z d>dd-d-d-d. d?d/Z d> d@d0Z dAfd1 Z!xZ"S)Bra 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@)rrFrDrGproxy proxy_configct |||tj|||||_||_||_d|_d|_d|_ d|_ d|_ y)N)hostportrrFrDF) super__init__rresolve_default_timeoutrGrPrQrHrIrKrMrN) selfrSrTrrFrDrGrPrQ __class__s rrVzHTTPConnection.__init__sr 33G<)  - (',$!%(,(,*.rc8|jjdS)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_hostrstriprXs rrSzHTTPConnection.hosts"~~$$S))rc||_y)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\)rXvalues rrSzHTTPConnection.hosts rc   tj|j|jf|j|j |j }tr,t!j"d||j|j|S#tj$r}t|j|||d}~wt$r-}t|d|jd|jd|d}~wt$r}t|d||d}~wwxYw)zoEstablish a socket connection and set nodelay settings on it. :return: New socket connection. )rFrGNzConnection to z timed out. (connect timeout=)z&Failed to establish a new connection: zhttp.client.connect)r+create_connectionr\rTrrFrGsocketgaierrorr%rS SocketTimeoutr#OSErrorr&_HAS_SYS_AUDITsysr<)rXsockes r _new_connzHTTPConnection._new_conns  //+ #22#22 D(  II+T499dii H # A%diiq9q @ %  +HVWX   $>qcB  s0A BDB.. D:(C"" D.C>>Dc^|dvrtd|dt| |||||_y)Nr8z$Invalid proxy scheme for tunneling: z", must be either 'http' or 'https')rTheaders) ValueErrorrU set_tunnelrN)rXrSrTrnschemerYs rrpzHTTPConnection.set_tunnelsF * *6vj@bc  4dG<$r) ctjj}d|jj d|j fz}|g}|j jD]+\}}|j|d|dj d-|jd|jdj|~|j|j|j} |j\}}} |tjj k7r/|j#t%d |d | j' |j(j+|d z} t-| |kDrtjj/d | sn/| d vrn*|j0dkDrt3d| j5}|j#y#|j#wxYw)NsCONNECT %s:%d HTTP/1.0 asciiz: z zlatin-1 r)methodzTunnel connection failed:  r z header line)rw rrzheader:)r9client_MAXLINErKencoderM_tunnel_headersitemsappendsendjoinresponse_classrj_method _read_status HTTPStatusOKclosergstripfpreadlinelen LineTooLong debuglevelprintdecode) rXr|connectrnheaderr`responseversioncodemessagelines r_tunnelzHTTPConnection._tunnels{{++H3!!((1!!7GiG!%!5!5!;!;!= &E7$7>>yIJ"> NN7 # IIchhw' (**499T\\*JH !+3+@+@+B($4??---JJL!$>tfAgmmoEV"WXX#;;//1 =D4y8+"kk55mDD44*i7  s *CGG+c|j|_|jrd|_|j t |j |_|jrd|_yy)NTF)rlrjrKrHrr@rPrBr^s rrzHTTPConnection.connectsUNN$   +/D ( LLN (,DJJ'7$  ' '%*D " (rc|jduSN)rjr^s r is_closedzHTTPConnection.is_closed'syyD  rcL|jyt|jd S)NFgr)rjrr^s r is_connectedzHTTPConnection.is_connected+s# 99  C888rc|jSr)rHr^s rhas_connected_to_proxyz%HTTPConnection.has_connected_to_proxy1s+++rcLt|jxr|jduS)zT Return True if a forwarding proxy is configured, else return False N)r@rPrKr^s rproxy_is_forwardingz"HTTPConnection.proxy_is_forwarding5s# DJJ=D$5$5$==rc t|d|_d|_d|_d|_d|_d|_d|_d|_ y#d|_d|_d|_d|_d|_d|_d|_d|_ wxYw)NF) rUrrjrArBrHrIrKrMrN)rXrYs rrzHTTPConnection.close<s ' GMODI$D %)D "+0D (%)D " $D  $D "&D DI$D %)D "+0D (%)D " $D  $D "&D s A :Bctj|}|r td|d|jdt|||||S)z+Method cannot contain non-token characters z (found at least rb) skip_hostskip_accept_encoding)_CONTAINS_CONTROL_CHAR_REsearchrogrouprU putrequest)rXrxurlrrmatchrYs rrzHTTPConnection.putrequestKsg*008 =fZGXY^YdYdYfXiijk w! C9CW"  rc0td|Dst||g|yt|j t vrNdj tt Dcgc]}tj|c}}td|dycc}w)rc3RK|]}t|txr |tk(!ywr) isinstancestrr)).0vs r z+HTTPConnection.putheader..as$Kq:a%:!{*::Ks%'z', 'z(urllib3.util.SKIP_HEADER only supports ''N) anyrU putheaderrlowerr*rsortedrtitlero)rXrvaluesskippable_headersrYs rrzHTTPConnection.putheader_sKFKK G f .v . FLLN #+< < & 178I1JKv6"K! :;L:MQO  =Ks BT)chunkedpreload_contentdecode_contentenforce_content_lengthc|j%|jj|jt||||||_|i}t d|D} d| v} d| v} |j ||| | t|||j} | j} | j}|rd| vrW|jdd nDd | vrd }n=d| vrd }n6d }|| 0d }|jdd n|jd t|d| vr|jdt|jD]\}}|j|||j| ^| D]Y}|st!|tr|j#d}|r |j%dt'||fzI|j%|[|r|j%dyy)N)request_method request_urlrrrc3NK|]}t|jywr)rr)rks rrz)HTTPConnection.request..sCaqwwy 1Cs#%zaccept-encodingrS)rr)rxrDztransfer-encodingzTransfer-Encodingrzcontent-lengthFTzContent-Lengthz user-agentz User-Agentzutf-8s%x %b s0 )rj settimeoutrr rI frozensetrr-rDchunkscontent_lengthrr_get_default_user_agentr endheadersrr}rr)rXrxrbodyrnrrrr header_keysrr chunks_and_clrrrr`chunks rrequestzHTTPConnection.requestms 99 II  ."2!+)#9 "  ?GC7CC 0K?k)   C.Bi  'tFdnnU %%&55 "+52I>  ;.$ 3 !))"&':IFNN#3S5HI { * NN<)@)B C$]]_MFE NN65 )-   eS)!LL1EIIoUU0CCDIIe$   IIl # rchtjdtd|j||||dy)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)rrnrN)warningswarnDeprecationWarningr)rXrxrrrns rrequest_chunkedzHTTPConnection.request_chunkeds4   X'  VStWd Krc|j t|j}d|_|jj|jddlm}t|!} t|jt#|jj%}||||j&|j(t+|dd|j,|j.|j0||j2|j4|j }|S#ttf$r7}tjdt||j |dYd}~d}~wwxYw) 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 z$Failed to parse headers (url=%s): %sT)exc_info _http_vsn_strzHTTP/?) rrnstatusrversion_stringreasonrroriginal_responserrr)rIrrjrrrr rU getresponsermsgr$ TypeErrorlogwarning_url_from_connectionrrrrrgetattrrrrrr)rX resp_optionsr httplib_responsehpernrrYs rrzHTTPConnection.getresponses@  ! ! )"$ $-- !% T\\* +!7.0  !"2"6"6 7!!1!5!5!;!;!=>!#**$,,"4(C#**(88'66.#/#F#F'66$00  1#I.  KK6$T<+C+CD    s%DE-EEr)rSrrTrLrrrFrErDrCrG&None | connection._TYPE_SOCKET_OPTIONSrP Url | NonerQProxyConfig | NonereturnNonerr)r`rrr)r socket.socket)NNr9) rSrrTrLrntyping.Mapping[str, str] | Nonerqrrrrr)rr@)FF) rxrrrrr@rr@rr)rrrrrr)NN)rxrrrr_TYPE_BODY | Nonernrrr@rr@rr@rr@rr) rxrrrrrrnrrr)rr )#rrr__doc__port_by_schemer>__annotations__rd IPPROTO_TCP TCP_NODELAYr?rArBrrVpropertyrSsetterrlrpri version_inforrrrrrrrrrrr __classcell__rYs@rrrTs0*8)?L&?   V//3PL K&*{)N**::!!..  / "215.D +////  / / //,//)/ /<**$ [[D 37 % % %1 %  %  % *$$ !L+"!!99 ,,>> '& %*      #    ( $#'37 _$ $#'+_$_$_$ _$ 1 _$_$_$_$!%_$ _$J#'37 LLL L 1 L  L&6 66rrceZdZUdZedZdZded<dZded<dZ ded<dZ d ed <dZ ded <dZ d ed <dZ d ed<dZded<dZded< deddej$ddddddddddddddddd dfdZ d ddZddZddZxZS)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_reqsrJca_certs ca_cert_dirNone | str | bytes ca_cert_data ssl_versionrLssl_minimum_versionssl_maximum_versionr.z!typing.Callable[..., None] | None_connect_callbackrO)rrFrDrGrPrQrassert_hostnamer.server_hostname ssl_contextrrrrr r cert_filekey_file key_passwordc t|||||||||||_||_||_| |_| |_| |_| |_||_ ||_ ||_ |xrtjj||_|xrtjj||_||_| .|j |j j$} n t'd} | |_d|_y)N)rTrrFrDrGrPrQ)rUrVrrrr r r r.rrr ospath expanduserrrr verify_moder1rr )rXrSrTrrFrDrGrPrQrr r.r r rrrrr rrrrrYs rrVzHTTPSConnection.__init__,s6  ))%  ! "(&.."4&#6 #6  ARWW%7%7%A &J277+=+=k+J(  + ,,88 -d3 "!%rc tjdtd|.|j|jj}n t d}||_||_||_||_ ||_ ||_ |xrtjj||_|xrtjj||_| |_y)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 rr1rrrrr r.rrrrrr) rXrrrrrr r.rrs rset_certzHTTPSConnection.set_certis   +(    + ,,88 -d3   ""(."4 ARWW%7%7%A &J277+=+=k+J(rc|j%|j|j}|j}n|j}|j}dtj vrt j||}nd}|j&|jdtj| |jx|_ }|j}d}|jn|jdk(r&|j|j|x|_ }d}n|jdk(rd|_d|_|j#|j}|j$ |j$}t&j(j+t,k}|r"t/j0d t,d t2|j5d }t7did |d |j8d|j:d|j<d|j>d|j@d|jBd|jDd|jFd|jHd|jJd|d|jLd|d|jNd|jP} | jR|_ |5| jRjYdk(} t jV||| |jZrd|_.n| j\|_.t_|j`|_|j r|j| j\|_yyy#tT$rN|j&|jdtj||t jV||dwxYw)Nh2)rSrTFzbefore connect) thread_idtarget_supports_http2r:Tr9zSystem time is way off (before z5). This will probably lead to SSL verification errorsr[rjrrrr rrrrrrr r  tls_in_tlsr r.zafter connect failure)rSrTsupports_http2r)1rKrMrSrTr,ALPN_PROTOCOLS http2_probeacquire_and_getr  threading get_identrlrjrN_connect_tls_proxyrBrHrr datetimedatetoday RECENT_DATErrr(r]#_ssl_wrap_socket_and_match_hostnamerrrr rrrrrrr r r.rd BaseExceptionset_and_releaseselected_alpn_protocolrrAr@rP) rXprobe_http2_hostprobe_http2_portrrjr r is_time_offserver_hostname_rm_dotsock_and_verifiedrs rrzHTTPSConnection.connects    (T->->-J#00 #00 #yy #yy  4&& &$/$?$?%,<% ! %* !  ! ! -  " " #--/&; #  I #~~/ /DI#'99OJ  ,&&'1'+'>'>tyy$'OODI!%J((F2-2D*04, "&"3"3##/"&"6"6"----/+=K 9+G::& &5%;%;C%@ " C!!..!!,,!%)$<$< ! %)$<$< !  !!,,!"..!..!!"..!!7!!,,!&!!% 4 4! $(#:#:!! $*00DI( ! (.55LLNRVVN  ' '%%-   # #$D 0<># &"3!>!> '''rr).rSrrTrLrrrFrErDrCrGrrPrrQrrrr "None | str | typing.Literal[False]r.rJr rJr ssl.SSLContext | NonerrJrrJrrrrLr rLrrrrJrrJrrJrr) NNNNNNNNN)rrJrrJrrrrJrrJr r5r.rJrrJrrrrr)r4rrjrrz ssl.SSLSocket)rrrrrr>rrrrrrrr r.r rrr?rVrrr#rrs@rrrs@ "'*L"&I&Hj"K"'+L$+$(K!(&**&**%) );?8?  ;& "215.<.S.S +/&*>B)-&*-1#"&+/*.*.(, $##'3;&;&;&  ;& / ;&;&,;&;&);&$;&<;&';&$;& +!;&"#;&$ %;&&)';&(();&*(+;&,&-;&./;&01;&2!3;&4 5;&~ $ $&*#'#>B)-"&+/')')')$ ') ! ')  ')<')'') '))') ')RGCR(rrc&eZdZUdZded<ded<y)_WrappedAndVerifiedSocketz[ Wrapped socket and whether the connection is verified after the TLS handshake zssl.SSLSocket | SSLTransportrdr@rAN)rrrrrrrrr8r89s )(rr8F)rc dd}|$d}tt|||t|}n|}t||_| s&| s$| dus tj stj sd|_|s"| s | s|rt|dr|j| 6| jd}d|vr|d|jd}t|r|} t|||||| | | || } | rt|jd | nd|jt j"k7rG|js;| dur7|j}|rd}nt%|d dxsd}t'|| xs| |t)||jt j*k(xs t-|  S#t.$r|j1wxYw) 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)rrr rload_default_certs[]%) rjkeyfilecertfilerrrrr r r) binary_formhostname_checks_common_name)rdrA)r/r2r1rr, IS_PYOPENSSLHAS_NEVER_CHECK_COMMON_NAMEcheck_hostnamehasattrr:rrfindr0r3_assert_fingerprint getpeercertssl CERT_NONEr_match_hostnamer8 CERT_REQUIREDr@r)r)rjrrrr rrrrrrr r.r r rdefault_ssl_contextcontext normalizedssl_sockcertr@s rr(r(Cs0 "(+K8 3 3' 2  +I6G   e #   //!&   G1 2""$ "$**40 * #$;j&6&6s&;>3C DE"22 6 !1 1 6 !%5 5  (  $!5,':Q WY Z \ G G NrcdtS)Nzpython-urllib3/r!rrrrrs [M **rceZdZdZy)DummyConnectionz-Used to detect a failed ConnectionCls import.N)rrrrrrrrbrbs7rrbct|trdnd}t||j|j|j S)zUReturns the URL from a given connection. This is mainly used for testing and logging.r:r9)rqrSrTr)rrr6rSrTr)connrrqs rrrs3 #49WvF f4994994 H L LLr)"rjrrNone | str | intrrerrLr rLrrJrrJrrJrrJrrJrrr r5r.rJr rJr r6rr@rr8)F)rPz_TYPE_PEER_CERT_RET_DICT | NonerSrr@r@rr)rY ExceptionrZrJrr'rr)rdz HTTPConnection | HTTPSConnectionrrJrr)e __future__rr$ http.clientr9loggingrrVrdrir!r2rr_HTTPConnectionrrrrf TYPE_CHECKINGrr util.ssl_r util.ssltransportr _collectionsrhttp2rr util.responser util.timeoutrrr util.utilr util.waitrrHSSLErrorr ImportErrorAttributeErrorr)_base_connectionrrr _versionr" exceptionsr#r$r%r&r'r(utilr)r*r+r, util.requestr-r.rFr/r0r1r2r3util.ssl_match_hostnamer4r5util.urlr6ConnectionErrorBrokenPipeError getLoggerrrrr%r'compilerrDrhr NamedTupler8r(rJr_rrbVerifiedHTTPSConnectionrrrrrs"  96(+ &3/('0BB$ <