a c'@sddlZddlmZmZmZmZmZmZmZm Z ddl m Z m Z ddl mZmZmZerdddlmZzddlmZWneyddlmZYn0edZee d Zee d ZGd d d eeeefZe eeeefeeeefeeeefeeeeffZeeed ed ddZeeeded ddZede eefe ed ddZde eefe ed ddZeeeedddZ!eeeeedddZ"de dddZ#dS) N)AnyStrcastListoverloadSequenceTuple TYPE_CHECKINGUnion) field_name field_value)bytesifyLocalProtocolErrorvalidate)Request)Literals[0-9]+asciic@seZdZdZdZeeeeefddddZe ddd Z e e d d d Z e dd dZedddZe eeefdddZeeeefdddZdS)Headersa A list-like interface that allows iterating over headers as byte-pairs of (lowercased-name, value). Internally we actually store the representation as three-tuples, including both the raw original casing, in order to preserve casing over-the-wire, and the lowercased name, for case-insensitive comparisions. r = Request( method="GET", target="/", headers=[("Host", "example.org"), ("Connection", "keep-alive")], http_version="1.1", ) assert r.headers == [ (b"host", b"example.org"), (b"connection", b"keep-alive") ] assert r.headers.raw_items() == [ (b"Host", b"example.org"), (b"Connection", b"keep-alive") ] _full_itemsN) full_itemsreturncCs ||_dSNr)selfrrY/workspaces/shunt/resources/test-fastapi/venv/lib/python3.9/site-packages/h11/_headers.py__init__fszHeaders.__init__)rcCs t|jSr)boolrrrrr__bool__iszHeaders.__bool__)otherrcCst|t|kSr)list)rr rrr__eq__lszHeaders.__eq__cCs t|jSr)lenrrrrr__len__oszHeaders.__len__cCsdtt|S)Nz )reprr!rrrr__repr__rszHeaders.__repr__)idxrcCs|j|\}}}||fSrr)rr'_namevaluerrr __getitem__uszHeaders.__getitem__cCsdd|jDS)NcSsg|]\}}}||fqSrr).0raw_namer(r*rrr zz%Headers.raw_items..rrrrr raw_itemsyszHeaders.raw_items)__name__ __module__ __qualname____doc__ __slots__rrbytesrrrobjectr"intr$strr&r+r0rrrrrKsrT)headers_parsedrcCsdSrrr:r;rrrnormalize_and_validatesr=FcCsdSrrr<rrrr=scCsdSrrr<rrrr=sc CsPg}d}d}|D]4\}}|sJt|}t|}tt|d|tt|d|t|tsXJt|tsfJ|}|}|dkrdd|dD}t|dkrt d | }tt |d |dur|}| |||fn||krt d q|d kr6|rt d d d|}|dkr t dd dd}| |||fq| |||fqt |S)NFzIllegal header name {!r}zIllegal header value {!r}scontent-lengthcSsh|] }|qSr)strip)r,lengthrrr r/z)normalize_and_validate..,r z"conflicting Content-Length headerszbad Content-Lengthstransfer-encodingz"multiple Transfer-Encoding headersi)Zerror_status_hintschunkedz,Only Transfer-Encoding: chunked is supportedT)r r_field_name_re_field_value_re isinstancer6lowersplitr#rpop_content_length_reappendr) r:r; new_headersZseen_content_lengthZsaw_transfer_encodingr)r*r-lengthsrrrr=sN     )r:r)rcCsPg}|jD]@\}}}||kr |}|dD]}|}|r.||q.q |S)NrA)rrErFr>rI)r:r)outr( found_namefound_raw_valueZfound_split_valuerrrget_comma_headers$rO)r:r) new_valuesrcCsPg}|jD] \}}}||kr |||fq |D]}|||fq0t|Sr)rrItitler=)r:r)rPrJZfound_raw_namerMrN new_valuerrrset_comma_headers rSr)requestrcCs"|jdkrdSt|jd}d|vS)Ns1.1Fsexpects 100-continue) http_versionrOr:)rTexpectrrrhas_expect_100_continues  rW)F)F)$retypingrrrrrrrr Z_abnfr r Z_utilr rrZ_eventsrr ImportErrorZtyping_extensionscompilerHencoderBrCr6rr9Z HeaderTypesr=rrOrSrWrrrrsL(  9 2   7/