1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
U
Þ=®dVã@s ddlmZddlZddlmZddlmZddlm    Z    ddl
m Z dd    d
d œd d „Z dddddddœdd„Z ddddddddœdd„Zdddddœdd„ZdS)é)Ú annotationsN)Úquoteé)Ú
_plain_int)Ú SecurityError)Ú
uri_to_iriÚstrzt.Iterable[str]Úbool)ÚhostnameÚ trusted_listÚreturnc    CsÖ|sdSz| d¡d d¡ d¡}Wntk
r<YdSXt|tƒrN|g}|D]~}| d¡rr|dd…}d    }nd}z| d¡d d¡ d¡}Wntk
r¬YdSX||ksÊ|rR| d|›¡rRd    SqRdS)
zôCheck 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ú:rÚidnaÚasciiÚ.éNT)Ú    partitionÚencodeÚdecodeÚUnicodeEncodeErrorÚ
isinstancerÚ
startswithÚendswith)r
r ÚrefZ suffix_match©rúLd:\z\workplace\vscode\pyvenv\venv\Lib\site-packages\werkzeug/sansio/utils.pyÚhost_is_trusted s(    
 
 
rz
str | Noneztuple[str, int | None] | Nonezt.Iterable[str] | None)ÚschemeÚ host_headerÚserverÚ trusted_hostsr cCs¤d}|dk    r|}n.|dk    r@|d}|ddk    r@|›d|d›}|dkr`| d¡r`|dd…}n|d    kr~| d
¡r~|dd …}|dk    r t||ƒs td |›d ƒ‚|S)a$Return 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.
    ÚNrrr >ÚhttpÚwsz:80éýÿÿÿ>ÚhttpsÚwssz:443éüÿÿÿzHost z is not trusted.)rrr)rrrr ÚhostrrrÚget_host1s  
r)z bytes | None)rr(Ú    root_pathÚpathÚ query_stringr cCs¨|d|g}|dkr*| d¡td |¡ƒS| t| d¡dd¡| d¡|dkrbtd |¡ƒS| t| d¡dd¡|rš| d¡| t|dd¡td |¡ƒS)    aƒRecreate 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!$&'()*+,/:;=?@%)ÚappendrÚjoinrÚrstripÚlstrip)rr(r*r+r,ÚurlrrrÚget_current_urlas
 
 
 
r5z
int | None)Úhttp_content_lengthÚhttp_transfer_encodingr cCs@|dks|dkrdSztdt|ƒƒWStk
r:YdSXdS)a¥Return 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)r6r7rrrÚget_content_lengthŒs r;)NN)NNN)NN)Ú
__future__rÚtypingÚtÚ urllib.parserÚ    _internalrÚ
exceptionsrÚurlsrrr)r5r;rrrrÚ<module>s      )ü3û,þ