;i~ddlmZddlZddlmZddlmZddlm Z ddl m Z d!dZ d"d#dZ d$d%dZ d"d&d ZdS)') annotationsN)quote) _plain_int) SecurityError) uri_to_irihostname str | None trusted_listt.Iterable[str]returnboolc(|sdS |dddd}n#t$rYdSwxYwt |t r|g}|D]}|dr |dd}d }nd} |dddd}n#t$rYdSwxYw||ks|r|d|rd SdS) zCheck if a host matches a list of trusted names. :param hostname: The name to check. :param trusted_list: A list of valid names to match. If a name starts with a dot it will match all subdomains. .. versionadded:: 0.9 F:ridnaascii.NT) partitionencodedecodeUnicodeEncodeError isinstancestr startswithendswith)r r ref suffix_matchs IC:\PYTHON\MyICR_Workspace\venv\Lib\site-packages\werkzeug/sansio/utils.pyhost_is_trustedr sV u%%c**1-44V<<CCGLL uu,$$&$~    >>#   !abb'CLL L --$$Q'..v66==gFFCC!   555  (??|?0A0A)c))0L0L?44 5s%AA AAAC C+*C+schemer host_headerservertuple[str, int | None] | None trusted_hostst.Iterable[str] | NonecVd}||}n5|3|d}d|vr|ddkrd|d}|d |d|d}|dvr |d r |dd }n#|d vr|d r |dd }|#t||std|d|S)aReturn the host for the given parameters. This first checks the ``host_header``. If it's not present, then ``server`` is used. The host will only contain the port if it is different than the standard port for the protocol. Optionally, verify that the host is trusted using :func:`host_is_trusted` and raise a :exc:`~werkzeug.exceptions.SecurityError` if it is not. :param scheme: The protocol the request used, like ``"https"``. :param host_header: The ``Host`` header value. :param server: Address of the server. ``(host, port)``, or ``(path, None)`` for unix sockets. :param trusted_hosts: A list of trusted host names. :return: Host, with port if necessary. :raise ~werkzeug.exceptions.SecurityError: If the host is not trusted. .. versionchanged:: 3.1.3 If ``SERVER_NAME`` is IPv6, it is wrapped in ``[]``. Nrr[]r>wshttpz:80>wsshttpsz:443zHost z is not trusted.)rr r)r!r"r#r%hosts rget_hostr21s: D  ay $;;47c>>t;;;D !9 ((VAY((D DMM%$8$8CRCy # # # f(=(= #CRCy t]33 B @ @ @ @AA A Kr1 root_pathpath query_string bytes | Nonec|d|g}|7|dtd|S|t|dd|d|"td|S|t|dd|r9|d|t|dtd|S) aRecreate the URL for a request. If an optional part isn't provided, it and subsequent parts are not included in the URL. The URL is an IRI, not a URI, so it may contain Unicode characters. Use :func:`~werkzeug.urls.iri_to_uri` to convert it to ASCII. :param scheme: The protocol the request used, like ``"https"``. :param host: The host the request was made to. See :func:`get_host`. :param root_path: Prefix that the application is mounted under. This is prepended to ``path``. :param path: The path part of the URL after ``root_path``. :param query_string: The portion of the URL after the "?". z://N/r(z!$&'()*+,/:;=@%)safe?z!$&'()*+,/:;=?@%)appendrjoinrrstriplstrip)r!r1r4r5r6urls rget_current_urlrAis( 5$ C 3"''#,,'''JJuY%%c**1BCCCDDDJJsOOO |"''#,,'''JJuT[[%%,=>>>???A 3 5,>???@@@ bggcll # ##r3http_content_lengthhttp_transfer_encoding int | Nonect|dks|dS tdt|S#t$rYdSwxYw)aReturn the ``Content-Length`` header value as an int. If the header is not given or the ``Transfer-Encoding`` header is ``chunked``, ``None`` is returned to indicate a streaming request. If the value is not an integer, or negative, 0 is returned. :param http_content_length: The Content-Length HTTP header. :param http_transfer_encoding: The Transfer-Encoding HTTP header. .. versionadded:: 2.2 chunkedNr)maxr ValueError)rBrCs rget_content_lengthrIsZ**.A.It1j!455666 qqs ) 77)r r r r r r)NN) r!rr"r r#r$r%r&r r)NNN) r!rr1rr4r r5r r6r7r r)rBr rCr r rD) __future__rtypingt urllib.parser _internalr exceptionsrurlsrr r2rArIr3rrRs""""""""""""&&&&&&####R-1,0 55555v!!% ($($($($($X'+)-r3