U em;@sddlmZddlZddlZddlmZddlmZdZe dZ e d Z e d ej ej BZd Zd Zd jeedZeedZdddddddddg ZdZddddeDdZded Zd!eded"Zd#Ze d$Ze d%ed&Ze d%ed&Ze d%ed&Ze d%edd'd&Ze d(ed)Z d*eeefZ!e e!ej ej BZ"e#d+Z$e#d,Z%e$e%Bd-hBZ&e&d.d/hBZ'e'd0hBZ(Z)Gd1d2d2e*d2d3ej+e,fd4ej+e,fd5ej+e,fd6ej+e-fd7ej+e,fd8ej+e,fd9ej+e,fgZ.ej/d:d;d:d<d=d>Z0ej/d?d;d?d<d@d>Z0dAd;dAd<dBd>Z0d:d:dCdDdEZ1ej/d?dAd?dFdGdHZ2ej/d:dAd:dFdIdHZ2dAdAdAdFdJdHZ2d:dKdLdMdNZ3d:d:dOdPdQZ4d:d2dRdSdTZ5dS)U) annotationsN)LocationParseError)to_str)httphttpsNz%[a-fA-F0-9]{2}z^(?:[a-zA-Z][a-zA-Z0-9+-]*:|/)zS^(?:([a-zA-Z][a-zA-Z0-9+.-]*):)?(?://([^\\/?#]*))?([^?#]*)(?:\?([^#]*))?(?:#(.*))?$z(?:[0-9]{1,3}\.){3}[0-9]{1,3}z[0-9A-Fa-f]{1,4}z(?:{hex}:{hex}|{ipv4}))hexZipv4)r ls32z(?:%(hex)s:){6}%(ls32)sz::(?:%(hex)s:){5}%(ls32)sz%(?:%(hex)s)?::(?:%(hex)s:){4}%(ls32)sz2(?:(?:%(hex)s:)?%(hex)s)?::(?:%(hex)s:){3}%(ls32)sz6(?:(?:%(hex)s:){0,2}%(hex)s)?::(?:%(hex)s:){2}%(ls32)sz/(?:(?:%(hex)s:){0,3}%(hex)s)?::%(hex)s:%(ls32)sz'(?:(?:%(hex)s:){0,4}%(hex)s)?::%(ls32)sz&(?:(?:%(hex)s:){0,5}%(hex)s)?::%(hex)sz(?:(?:%(hex)s:){0,6}%(hex)s)?::zCABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789._\-~z(?:|cCsg|] }|tqS)_subs).0xr r >/opt/hc_python/lib/python3.8/site-packages/urllib3/util/url.py 4sr)z (?:%25|%)(?:[z]|%[a-fA-F0-9]{2})+z\[z)?\]z!(?:[^\[\]%:/?#]|%[a-fA-F0-9]{2})*z!^(/[^?#]*)(?:\?([^#]*))?(?:#.*)?$^$(z)\]$z)^(%s|%s|%s)(?::0*?(|0|[1-9][0-9]{0,4}))?$zBABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789._-~z !$&'()*+,;=:@/?c seZdZdZdddddddddfdd Zeddd d Zed dd d ZeddddZeddddZ ed dddZ d dddZ Z S)Urlz Data structure for representing an HTTP URL. Used as a return value for :func:`parse_url`. Both the scheme and host are normalized as they are both case-insensitive according to RFC 3986. N str | Nonez int | Noneschemeauthhostportpathqueryfragmentc s@|r|dsd|}|dk r&|}t||||||||S)Nr) startswithlowersuper__new__)clsrrr r!r"r#r$ __class__r rr(ds z Url.__new__)returncCs|jS)z@For backwards-compatibility with urlparse. We're nice like that.)r selfr r rhostnametsz Url.hostnamestrcCs&|jpd}|jdk r"|d|j7}|S)z)Absolute path including the query string.rNr)r"r#)r.urir r r request_uriys  zUrl.request_uricCs2|j}|j}|dks|dkr |S|d|SdS)z Authority component as defined in RFC 3986 3.2. This includes userinfo (auth), host and port. i.e. userinfo@host:port Nr)rnetloc)r.userinfor3r r r authoritys z Url.authoritycCs,|jdkrdS|jr&|jd|jS|jS)z Network location including host and port. If you need the equivalent of urllib.parse's ``netloc``, use the ``authority`` property instead. Nr)r r!r-r r rr3s  z Url.netlocc Cs|\}}}}}}}d}|dk r*||d7}|dk r>||d7}|dk rN||7}|dk rf|dt|7}|dk rv||7}|dk r|d|7}|dk r|d|7}|S)a2 Convert self into a url This function should more or less round-trip with :func:`.parse_url`. The returned url may not be exactly the same as the url inputted to :func:`.parse_url`, but it should be equivalent by the RFC (e.g., urls with a blank port will have : removed). Example: .. code-block:: python import urllib3 U = urllib3.util.parse_url("https://google.com/mail/") print(U.url) # "https://google.com/mail/" print( urllib3.util.Url("https", "username:password", "host.com", 80, "/path", "query", "fragment" ).url ) # "https://username:password@host.com:80/path?query#fragment" Nz://rrr#)r0) r.rrr r!r"r#r$urlr r rr8s"    zUrl.urlcCs|jSN)r8r-r r r__str__sz Url.__str__)NNNNNNN) __name__ __module__ __qualname____doc__r(propertyr/r2r5r3r8r: __classcell__r r r*rrPs(   /rrrr r!r"r#r$r0ztyping.Container[str]) component allowed_charsr,cCsdSr9r rArBr r r_encode_invalid_charssrDNonecCsdSr9r rCr r rrDsrc Cs|dkr |St|}tdd|\}}|dd}||dk}t}tdt|D]n}|||d}t|}|r~|dks|d kr| |kr||7}qV| dt |d d d  qV| S) zfPercent-encodes a URI component without reapplying onto an already percent-encoded component. NcSs|dS)Nr)groupupper)matchr r rz'_encode_invalid_chars..zutf-8 surrogatepass%rrr)r _PERCENT_REsubnencodecount bytearrayrangelenorddecodeextendr zfillrG) rArBpercent_encodings uri_bytesis_percent_encodedencoded_componentibytebyte_ordr r rrDs,   *)r"r,cCs|d}g}|D].}|dkr q|dkr4||q|r|q|drd|rX|drd|dd|drx|dd|S)Nr.z..rr6)z/.z/..)splitappendpopr%insertendswithjoin)r"segmentsoutputsegmentr r r_remove_path_dot_segmentss      rj)r rr,cCsdSr9r r rr r r_normalize_host%srlcCsdSr9r rkr r rrl*scCs|r|tkrt|}|rt|}|r|d\}}|||}|drb|dkrb|dd}n |dd}t|t}|d| d|||dS| Sn*t |st d dd| dDd S|S) Nrz%25%.cSsg|] }t|qSr ) _idna_encode)rlabelr r rrFsz#_normalize_host..r`ascii)_NORMALIZABLE_SCHEMES_IPV6_ADDRZ_RErH _ZONE_ID_REsearchspanr%rD_UNRESERVED_CHARSr&_IPV4_RErrfra)r ris_ipv6rHstartendzone_idr r rrl/s(     &  bytes)namer,cCs|stz ddl}Wntk r2tddYnXz|j|dddWS|jk rrtd|ddYnX|dS)Nrz-Unable to parse URL without the 'idna' moduleT)strict std3_ruleszName 'z' is not a valid IDNA labelrr)isasciiidna ImportErrorrrPr& IDNAError)rrr r rrpLs$  rp)targetr,cCsTt|}|st|d|\}}t|t}|dk rPt|t}|d|7}|S)zPercent-encodes a request target so that there are no invalid characters Pre-condition for this function is that 'target' must start with '/'. If that is the case then _TARGET_RE will always produce a match. z is not a valid request URINr) _TARGET_RErHrgroupsrD _PATH_CHARS _QUERY_CHARS)rrHr"r#Zencoded_targetr r r_encode_target_s     r)r8r,c Cs|s tS|}t|s d|}zt|\}}}}}|dkpN|tk}|r\|}|r|d\}} } |pvd}t | \} } |r|rt |t }| dkrd} n d\}} } | dk rt | } d| krdksnt |nd} t| |} |r|rt|}t |t}|r&|r&t |t}|r<|rs                   $