xjZ ddlmZddlZddlZddlZddlZddlmZddlm Z ejrddl m Z ddZ ddZddd Zddd Zdd Zdd ZGd dZddZddZy)) annotationsN) getproxies) PrimitiveDataURLc2|dury|dury|yt|S)z Coerce a primitive data type into a string value. Note that we prefer JSON-style 'true'/'false' for boolean values here. TtrueFfalse)str)values a/mnt/ssd/data/Dropbox/adrian/sandbox/mcp-query/venv/lib/python3.12/site-packages/httpx2/_utils.pyprimitive_value_to_strrs*  } %  u:ct}i}dD]*}|j|s||}d|vr|nd|||d<,|jddjdDcgc]}|j}}|D]}|dk(ricS|sd|vrd||<t |r d|d |<-t |r/d |vr!|j d \}}}d|d |d |<]d|d |d <g|jdk(r d|d |<d|d|<|Scc}w)z+Gets proxy information from the environment)httphttpsallz://zhttp://nor ,*Nzall:///zall://[z]/] localhostzall://*)rgetsplitstripis_ipv4_hostnameis_ipv6_hostname partitionlower) proxy_infomountsschemehostnamehostno_proxy_hostsaddr_subnets rget_environment_proxiesr,shJ$&F*] >>& !!&)H16(1BX'RZQ[H\FfXS> "] 0:~~dB/G/M/Mc/RStdjjlSNS"4 s? I  #'x !(+.2z*+!(+(?&.&8&8&=OD!V9=FWTF"VH5648FWXJa01![0.2z*+/3 +,=4@ MCTsD cHt|tr|j|S|SN isinstancer encoderencodings rto_bytesr4Qs%/s%;5<< !FFrcHt|tr|S|j|Sr.)r0r decoder2s rto_strr7Usuc*5F X0FFrcFt|tr|S|jSr.r/)r match_type_ofs rto_bytes_or_strr:Ys}c25F FrcB |j}tj|j}|S#tt f$r\ |j }|jdtj}|j|Y|S#tt f$rYYywxYwwxYw)zs Given a file-like stream object, return its length in number of bytes without reading it into memory. rN) filenoosfstatst_sizeAttributeErrorOSErrortellseekSEEK_END)streamfdlengthoffsets rpeek_filelike_lengthrI]s  ]]_"%% M G $  [[]F[[BKK0F KK  M (   s(/3BABBBBBcJeZdZdZd dZd dZed dZd dZd dZ ddZ y) URLPatterna A utility class currently used for making lookups against proxy keys... # Wildcard matching... >>> pattern = URLPattern("all://") >>> pattern.matches(httpx2.URL("http://example.com")) True # Witch scheme matching... >>> pattern = URLPattern("https://") >>> pattern.matches(httpx2.URL("https://example.com")) True >>> pattern.matches(httpx2.URL("http://example.com")) False # With domain matching... >>> pattern = URLPattern("https://example.com") >>> pattern.matches(httpx2.URL("https://example.com")) True >>> pattern.matches(httpx2.URL("http://example.com")) False >>> pattern.matches(httpx2.URL("https://other.com")) False # Wildcard scheme, with domain matching... >>> pattern = URLPattern("all://example.com") >>> pattern.matches(httpx2.URL("https://example.com")) True >>> pattern.matches(httpx2.URL("http://example.com")) True >>> pattern.matches(httpx2.URL("https://other.com")) False # With port matching... >>> pattern = URLPattern("https://example.com:1234") >>> pattern.matches(httpx2.URL("https://example.com:1234")) True >>> pattern.matches(httpx2.URL("https://example.com")) False c8ddlm}|rd|vrtd|d|d||}||_|jdk(rdn |j|_|j d k(rdn |j |_|j |_|j r|j d k(rd|_y|j jd rAtj|j d d}tjd |d |_y|j jd rAtj|j dd}tjd|d |_ytj|j }tjd|d |_y)Nrr:zUProxy keys should use proper URL forms rather than plain scheme strings. Instead of "z", use "z://"rr rz*.z^.+\.$z^(.+\.)?^) _urlsr ValueErrorpatternr%r'port host_regex startswithreescapecompile)selfrSrurldomains r__init__zURLPattern.__init__sI s')&ixy>  'l JJ%/bSZZ ((c/Bsxx HH xx388s?:>DO XX  &YYsxx|,F jj6&);?DOYYsxx(F jj1VHA7DOrc|jr|j|jk7ry|jr2|j&|jj|jsy|j|j|jk7ryy)NFT)r%r'rUmatchrTrZothers rmatcheszURLPattern.matchesse ;;4;;%,,6 994T__=R=RSXS]S]=^ 99 TYY%**%<rc|jdnd}t|j }t|j }|||fS)z The priority allows URLPattern instances to be sortable, so that we can match from most specific to least specific. rr)rTlenr'r%)rZ port_priority host_priorityscheme_prioritys rpriorityzURLPattern.prioritysA"YY2 TYY t{{++}o>>rc,t|jSr.)hashrS)rZs r__hash__zURLPattern.__hash__sDLL!!rc4|j|jkSr.)rhr`s r__lt__zURLPattern.__lt__s}}u~~--rcXt|txr|j|jk(Sr.)r0rKrSr`s r__eq__zURLPattern.__eq__s!%,N1NNrN)rSr returnNone)rarrpbool)rpztuple[int, int, int])rpint)rarKrprr)ra typing.Anyrprr) __name__ __module__ __qualname____doc__r]rbpropertyrhrkrmrorrrKrKvs6'R8< ? ?".OrrKcr tj|jddy#t$rYywxYwNrrFT) ipaddress IPv4Addressr Exceptionr&s rrr<hnnS1!45   '* 66cr tj|jddy#t$rYywxYwr|)r} IPv6Addressrrrs rr r rr)rrrpr )rpzdict[str, str | None])zutf-8)r str | bytesr3r rpbytes)rrr3r rpr )rr r9 typing.AnyStrrpr)rErtrpz int | None)r&r rprr) __future__rr}r=rWtypingurllib.requestr_typesr TYPE_CHECKINGrQrrr,r4r7r:rIrKrr rzrrrsa" %!  0fGGG2fOfORr