+
    DfjMa                        R t ^ RIHt ^ RIHt ^ RIHtHt ^ RIH	t	H
t
Ht ^ RIHtHtHt  ! R R]4      tR R	 lt ! R
 R]4      t ! R R]4      t ! R R]4      tR# )z(
Tests for L{twisted.web.http_headers}.
)annotations)Sequence)SynchronousTestCaseTestCase)HeadersInvalidHeaderName_nameEncoder)bytesLinearWhitespaceComponentssanitizedBytestextLinearWhitespaceComponentsc                  >    ] tR t^tRtR R ltR R ltR R ltRtR	# )
NameEncoderTestsz/
Test L{twisted.web.http_headers._NameEncoder}
c                   V ^8  d   QhRR/#    returnNone )formats   "D/usr/lib/python3/dist-packages/twisted/web/test/test_http_headers.py__annotate__NameEncoderTests.__annotate__   s     X X X    c                J   V P                  \        P                  ! R4      R4       V P                  \        P                  ! R4      R4       V P                  \        P                  ! R4      R4       V P                  \        P                  ! R4      R4       V P                  \        P                  ! R	4      R
4       V P                  \        P                  ! R4      R4       V P                  \        P                  ! R4      R4       V P                  \        P                  ! R4      R4       V P                  \        P                  ! R4      R4       V P                  \        P                  ! R4      R4       V P                  \        P                  ! R4      R4       R# )zS
L{_NameEncoder.encode} returns the canonical capitalization for
the given header.
   test   Tests
   test-stuff
   Test-Stuffs   content-md5   Content-MD5s   dnt   DNTs   etag   ETags   p3p   P3Ps   te   TE   www-authenticate   WWW-Authenticates   WWW-authenticates   Www-Authenticates   x-xss-protection   X-XSS-ProtectionNassertEqualr   encodeselfs   &r   test_encodeName NameEncoderTests.test_encodeName   s5   
 	,,W5w?,,];]K,,^<nM,,V4f=,,W5w?,,V4f=,,U3U;,,-@ACVW,,-@ACVW,,-@ACVW,,-@ACVWr   c                   V ^8  d   QhRR/# r   r   )r   s   "r   r   r   +   s     W WD Wr   c                J   V P                  \        P                  ! R4      R4       V P                  \        P                  ! R4      R4       V P                  \        P                  ! R4      R4       V P                  \        P                  ! R4      R4       V P                  \        P                  ! R	4      R
4       V P                  \        P                  ! R4      R4       V P                  \        P                  ! R4      R4       V P                  \        P                  ! R4      R4       V P                  \        P                  ! R4      R4       V P                  \        P                  ! R4      R4       V P                  \        P                  ! R4      R4       R# )zb
L{_NameEncoder.encode} returns the canonical capitalization for
a header name given as a L{str}.
testr   z
test-stuffr   content-md5r   dntr   etagr   p3pr    ter!   www-authenticater#   zWWW-authenticatezWww-Authenticatezx-xss-protectionr$   Nr%   r(   s   &r   test_encodeNameStr#NameEncoderTests.test_encodeNameStr+   s5   
 	,,V4g>,,\:MJ,,];^L,,U3V<,,V4g>,,U3V<,,T2E:,,-?@BUV,,-?@BUV,,-?@BUV,,-?@BUVr   c                   V ^8  d   QhRR/# r   r   )r   s   "r   r   r   <   s     	
 	
t 	
r   c                    \        4       p\        \        P                  ^,           4       F  pVP	                  RV 2R4       K  	  V P                  \        \        P                  4      \        P                  4       R# )z8
Only a limited number of HTTP header names get cached.
zhello-valueN)r   ranger   _MAX_CACHED_HEADERSaddRawHeaderr&   len_canonicalHeaderCache)r)   headersis   &  r   test_maxCachedHeaders&NameEncoderTests.test_maxCachedHeaders<   s_     )|77#=>A  6!w7 ?223\5U5U	
r   r   N)	__name__
__module____qualname____firstlineno____doc__r*   r5   rA   __static_attributes__r   r   r   r   r      s    X"W"	
 	
r   r   c               (    V ^8  d   QhRRRRRRRR/# )	r   testCaser   
componentszSequence[bytes] | Sequence[str]expectedbytesr   r   r   )r   s   "r   r   r   H   s2      I  I I$C IOT I	 Ir   c                   RpV F  p. pVP                  \        W4./4      4       \        4       pVP                  W44       VP                  V4       \        4       pVP                  W4.4       VP                  V4       V FQ  pV P	                  \        VP                  4       4      W2.3.4       V P	                  VP                  V4      V.4       KS  	  K  	  R# )a  
Assert that the components are sanitized to the expected value as
both a header value, across all of L{Header}'s setters and getters.

@param testCase: A test case.

@param components: A sequence of values that contain linear
    whitespace to use as header values; see
    C{textLinearWhitespaceComponents} and
    C{bytesLinearWhitespaceComponents}

@param expected: The expected sanitized form of the component as
    a header value.
s   NameN)appendr   r<   setRawHeadersr&   listgetAllRawHeadersgetRawHeaders)	rJ   rK   rL   name	componentr?   added	setHeaderheaders	   &&&      r   assertSanitizedrY   H   s    " D	wk234	4+uI	k2y!F  f&=&=&?!@D*CUBVW  !5!5d!;hZH   r   c                      ] tR t^ktRtR R ltR R ltR R ltR R	 ltR
 R lt	R R lt
R R ltR R ltR R ltR R ltR R ltR R ltR R ltR R ltR R ltR  R! ltR" R# ltR$ R% ltR& R' ltR(tR)# )*BytesHeadersTestsz=
Tests for L{Headers}, using L{bytes} arguments for methods.
c                   V ^8  d   QhRR/# r   r   )r   s   "r   r   BytesHeadersTests.__annotate__p   s     O Ot Or   c                0    \        V \        \        4       R# zN
Linear whitespace in header names or values is replaced with a
single space.
N)rY   r	   r
   r(   s   &r   test_sanitizeLinearWhitespace/BytesHeadersTests.test_sanitizeLinearWhitespacep   s    
 	=~Nr   c                   V ^8  d   QhRR/# r   r   )r   s   "r   r   r]   w   s     < <$ <r   c                f    \        RR./4      pV P                  VP                  R4      R.4       R# )z`
The header values passed to L{Headers.__init__} can be retrieved via
L{Headers.getRawHeaders}.
s   Foo   bar   fooNr   r&   rS   r)   hs   & r   test_initializer"BytesHeadersTests.test_initializerw   s0    
 VfX&'06(;r   c                   V ^8  d   QhRR/# r   r   )r   s   "r   r   r]      s     
= 
=D 
=r   c                   RR.p\        4       pVP                  RV4       V P                  VP                  R4      4       V P                  VP                  R4      4       V P	                  VP                  R4      V4       R# )zr
L{Headers.setRawHeaders} sets the header values for the given
header name to the sequence of byte string values.
   value1   value2r   r   Nr   rP   
assertTrue	hasHeaderr&   rS   )r)   rawValuerh   s   &  r   test_setRawHeaders$BytesHeadersTests.test_setRawHeaders   sf    
 y)I	*G,-G,-18<r   c                   V ^8  d   QhRR/# r   r   )r   s   "r   r   r]      s     I I4 Ir   c                    \        4       pVP                  RR4       V P                  VP                  R4      R.4       VP                  RR4       V P                  VP                  R4      RR.4       R# )>
L{Headers.addRawHeader} adds a new value for a given header.
r      lemur   pandaNr   r<   r&   rS   rg   s   & r   test_addRawHeader#BytesHeadersTests.test_addRawHeader   s`     I	w)1H:>	w)1Hh3GHr   c                   V ^8  d   QhRR/# r   r   )r   s   "r   r   r]      s     < <T <r   c                V    V P                  \        4       P                  R4      4       R# )b
L{Headers.getRawHeaders} returns L{None} if the header is not found and
no default is specified.
r   NassertIsNoner   rS   r(   s   &r   test_getRawHeadersNoDefault-BytesHeadersTests.test_getRawHeadersNoDefault   s    
 	')11':;r   c                   V ^8  d   QhRR/# r   r   )r   s   "r   r   r]      s     I I Ir   c                r    \        4       p\        4       pV P                  VP                  RV4      V4       R# )W
L{Headers.getRawHeaders} returns the specified default value when no
header is found.
r   N)r   objectassertIdenticalrS   r)   rh   defaults   &  r   test_getRawHeadersDefaultValue0BytesHeadersTests.test_getRawHeadersDefaultValue   s-    
 I(Q__Wg>Hr   c                   V ^8  d   QhRR/# r   r   )r   s   "r   r   r]      s     
G 
GD 
Gr   c                    \        4       pR.pVP                  RV4       V P                  VP                  RV4      ^ ,          \        4       V P                  VP                  RV4      R.4       R# )z
If the object passed as the value list to L{Headers.setRawHeaders}
is later passed as a default to L{Headers.getRawHeaders}, the
result nevertheless contains encoded values.
r9      key   valueN)r   rP   assertIsInstancerS   rM   r&   r   s   &  r   *test_getRawHeadersWithDefaultMatchingValue<BytesHeadersTests.test_getRawHeadersWithDefaultMatchingValue   s]     I)	(aoofg>qA5I9H:Fr   c                   V ^8  d   QhRR/# r   r   )r   s   "r   r   r]      s     ? ?D ?r   c                    \        4       pVP                  RR.4       V P                  VP                  R4      R.4       V P                  VP                  R4      R.4       R# )U
L{Headers.getRawHeaders} returns the values which have been set for a
given header.
r   rx   r   Nr   rP   r&   rS   rg   s   & r   test_getRawHeaders$BytesHeadersTests.test_getRawHeaders   sQ    
 I	(,1H:>1H:>r   c                   V ^8  d   QhRR/# r   r   )r   s   "r   r   r]      s     . .D .r   c                    \        4       pVP                  RR.4       V P                  VP                  R4      4       V P                  VP                  R4      4       R# )Q
Check that L{Headers.hasHeader} returns C{True} when the given header
is found.
r   rx   r   Nr   rP   rp   rq   rg   s   & r   test_hasHeaderTrue$BytesHeadersTests.test_hasHeaderTrue   sE    
 I	(,G,-G,-r   c                   V ^8  d   QhRR/# r   r   )r   s   "r   r   r]      s     7 7T 7r   c                V    V P                  \        4       P                  R4      4       R# )K
L{Headers.hasHeader} returns C{False} when the given header is not
found.
r   NassertFalser   rq   r(   s   &r   test_hasHeaderFalse%BytesHeadersTests.test_hasHeaderFalse   s    
 	,,W56r   c                   V ^8  d   QhRR/# r   r   )r   s   "r   r   r]      s     . .4 .r   c                   \        4       pVP                  RR.4       V P                  VP                  R4      4       VP	                  R4       V P                  VP                  R4      4       VP                  RR.4       V P                  VP                  R4      4       VP	                  R4       V P                  VP                  R4      4       R# )>
Check that L{Headers.removeHeader} removes the given header.
re   rx   rd   ry   s   BarNr   rP   rp   rq   removeHeaderr   rg   s   & r   test_removeHeader#BytesHeadersTests.test_removeHeader   s     I	
+F+,	vV,-	
+F+,	vV,-r   c                   V ^8  d   QhRR/# r   r   )r   s   "r   r   r]           9 9d 9r   c                    \        4       pVP                  R4       V P                  \        VP	                  4       4      . 4       R# )S
L{Headers.removeHeader} is a no-operation when the specified header is
not found.
r   Nr   r   r&   rQ   rR   rg   s   & r   test_removeHeaderDoesntExist.BytesHeadersTests.test_removeHeaderDoesntExist   s5    
 I	wa0023R8r   c                   V ^8  d   QhRR/# r   r   )r   s   "r   r   r]           
 
t 
r   c                    \        4       pVP                  RR.4       VP                  RR.4       VP                  4        UUu0 uF  w  r#V\        V4      3kK  	  pppV P	                  VRR04       R# u uppi )
L{Headers.getAllRawHeaders} returns an iterable of (k, v) pairs, where
C{k} is the canonicalized representation of the header name, and C{v}
is a sequence of values.
r      lemursr"      basic aksljdlk=Nr#   )r   r   )r   r   rP   rR   tupler&   r)   rh   kv
allHeaderss   &    r   test_getAllRawHeaders'BytesHeadersTests.test_getAllRawHeaders   sw     I	)-	+.@-AB010B0B0DE0Dq%(m0D
E9;RS	
 Fs   A5c                   V ^8  d   QhRR/# r   r   )r   s   "r   r   r]      s     * * *r   c                   \        4       pVP                  RR.4       \        4       pVP                  RR.4       \        4       pVP                  RRR.4       V P                  W4       V P                  W4       V P                  W4       R# )i
A L{Headers} instance compares equal to itself and to another
L{Headers} instance with the same values.
re   ry   rx   Nr   rP   r&   assertNotEqual)r)   firstsecondthirds   &   r   test_headersComparison(BytesHeadersTests.test_headersComparison   s|    
 	FXJ/VhZ0	FXx$89&'E)r   c                   V ^8  d   QhRR/# r   r   )r   s   "r   r   r]     s     ' 'd 'r   c                    \        4       pV P                  VR4       V P                  V\        4       4       V P                  VR4       R# )N
An instance of L{Headers} does not compare equal to other unrelated
objects.
re   Nr   r   r   r   rg   s   & r   test_otherComparison&BytesHeadersTests.test_otherComparison  s=    
 IAr"Avx(Av&r   c                   V ^8  d   QhRR/# r   r   )r   s   "r   r   r]     s     
 
4 
r   c           
         RpRpRpV P                  \        \        WV./4      4      RVP                  4       : RV: RV: R24       R# )	za
The L{repr} of a L{Headers} instance shows the names and values of all
the headers it contains.
re   rd      baz	Headers({: [, ]})Nr&   reprr   
capitalizer)   foobarbazs   &   r   	test_reprBytesHeadersTests.test_repr  sU    
 #Sz*+,),CwbtD	
r   c                   V ^8  d   QhRR/# r   r   )r   s   "r   r   r]     r   r   c           
         RpRpRpV P                  \        \        WV./4      4      RVP                  4       : RV: RV: R24       R# )	z
The L{repr} of a L{Headers} instance shows the names and values of all
the headers it contains, not attempting to decode any raw bytes.
re   s   bars   bazr   r   r   r   Nr   r   s   &   r   test_reprWithRawBytes'BytesHeadersTests.test_reprWithRawBytes  sW      #Sz*+,),CwbtD	
r   c                   V ^8  d   QhRR/# r   r   )r   s   "r   r   r]   -  s     
 
4 
r   c           
         RpRpRp ! R R\         4      pV P                  \        V! WV./4      4      RVP                  4       : RV: RV: R	24       R
# )z
The L{repr} of an instance of a subclass of L{Headers} uses the name
of the subclass instead of the string C{"Headers"}.
re   rd   r   c                      ] tR tRtRtR# )9BytesHeadersTests.test_subclassRepr.<locals>.FunnyHeadersi6  r   NrC   rD   rE   rF   rH   r   r   r   FunnyHeadersr   6      r   r   FunnyHeaders({r   r   r   N)r   r&   r   r   )r)   r   r   r   r   s   &    r   test_subclassRepr#BytesHeadersTests.test_subclassRepr-  sc    
 	7 	 	s#J/01cnn.1SG2cWDI	
r   c                   V ^8  d   QhRR/# r   r   )r   s   "r   r   r]   >  s     E E4 Er   c                v   \        4       pVP                  RR.4       VP                  4       pV P                  VP	                  R4      R.4       VP                  RR4       V P                  VP	                  R4      R.4       VP                  RR4       V P                  VP	                  R4      RR.4       R# )
L{Headers.copy} creates a new independent copy of an existing
L{Headers} instance, allowing future modifications without impacts
between the copies.
r   re   rd   r   Nr   rP   copyr&   rS   r<   r)   rh   r@   s   &  r   	test_copyBytesHeadersTests.test_copy>  s     I	&*FFH1F8<	w'1F8<	w'1FF3CDr   r   N)rC   rD   rE   rF   rG   r`   ri   rs   r{   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   rH   r   r   r   r[   r[   k   sq    O<
=I<I
G?.7. 9
"*'

"
"E Er   r[   c                  "   ] tR tRtRtR R ltR R ltR R ltR	 R
 ltR R lt	R R lt
R R ltR R ltR R ltR R ltR R ltR R ltR R ltR R ltR R  ltR! R" ltR# R$ ltR% R& ltR' R( ltR) R* ltR+ R, ltR- R. ltR/tR0# )1UnicodeHeadersTestsiN  z;
Tests for L{Headers}, using L{str} arguments for methods.
c                   V ^8  d   QhRR/# r   r   )r   s   "r   r    UnicodeHeadersTests.__annotate__S  s     N Nt Nr   c                0    \        V \        \        4       R# r_   )rY   r   r
   r(   s   &r   r`   1UnicodeHeadersTests.test_sanitizeLinearWhitespaceS  s    
 	<nMr   c                   V ^8  d   QhRR/# r   r   )r   s   "r   r   r   Z  s     
: 
:$ 
:r   c                    \        RR./4      pV P                  VP                  R4      R.4       V P                  VP                  R4      R.4       R# )a  
The header values passed to L{Headers.__init__} can be retrieved via
L{Headers.getRawHeaders}. If a L{bytes} argument is given, it returns
L{bytes} values, and if a L{str} argument is given, it returns
L{str} values. Both are the same header value, just encoded or
decoded.
Foor   re   rd   r   Nrf   rg   s   & r   ri   $UnicodeHeadersTests.test_initializerZ  sK     UUG$%06(;/%9r   c                   V ^8  d   QhRR/# r   r   )r   s   "r   r   r   f  s     D DD Dr   c                   RR.pRR.p\        4       pVP                  RV4       V P                  VP                  R4      4       V P                  VP                  R4      4       V P                  VP                  R4      4       V P                  VP                  R4      4       V P	                  VP                  R4      V4       V P	                  VP                  R4      V4       R	# )
zp
L{Headers.setRawHeaders} sets the header values for the given
header name to the sequence of strings, encoded.
value1value2rm   rn   r.   r   r   TestNro   )r)   rr   rawEncodedValuerh   s   &   r   rs   &UnicodeHeadersTests.test_setRawHeadersf  s    
 h'$i0I	)G,-G,-F+,F+,0(;1?Cr   c                   V ^8  d   QhRR/# r   r   )r   s   "r   r   r   v  s     " "t "r   c                H   \        4       pV P                  \        4      ;_uu_ 4        VP                  RR.4       RRR4       V P                  \        4      ;_uu_ 4        VP	                  R4       RRR4       R#   + '       g   i     LI; i  + '       g   i     R# ; i)z
Passing L{str} to any function that takes a header name will encode
said header name as ISO-8859-1, and if it cannot be encoded, it will
raise a L{UnicodeDecodeError}.
   ☃valN)r   assertRaisesUnicodeEncodeErrorrP   rq   rg   s   & r   test_nameNotEncodable)UnicodeHeadersTests.test_nameNotEncodablev  sq     I 122OOHug. 3 122KK! 32 32 322s   A=!B=B	B!	c                   V ^8  d   QhRR/# r   r   )r   s   "r   r   r     s     P P4 Pr   c                x   \        4       pV P                  \        VP                  RR.4       V P                  \        VP                  RR.4       V P                  \        VP                  RR.4       V P                  \        VP                  RR.4       V P                  \        VP                  RR.4       R# )zl
HTTP header names must be tokens, so any names containing non-token
characters raises L{InvalidHeaderName}
   s   val   ás   a bzc
dzc	dN)r   r  r   rP   rg   s   & r   test_nameNotToken%UnicodeHeadersTests.test_nameNotToken  s    
 I 	+Q__gxP+Q__hQ 	+Q__fvhO+Q__fvhO+Q__fvhOr   c                   V ^8  d   QhRR/# r   r   )r   s   "r   r   r     s     , ,4 ,r   c                   \        4       pVP                  RR.4       V P                  VP                  R4      4       V P	                  VP                  R4      R.4       V P                  VP                  R4      4       R# )ze
Passing L{str} to any function that takes a header name will encode
said header name as ISO-8859-1.
r   re   rd   Nro   rg   s   & r   test_nameEncoding%UnicodeHeadersTests.test_nameEncoding  sf    
 I 	
x( 	F+,06(; 	E*+r   c                   V ^8  d   QhRR/# r   r   )r   s   "r   r   r     s     K Kd Kr   c                    \        4       pVP                  RRR.4       V P                  VP                  R4      4       V P	                  VP                  R4      RR.4       R# )zd
Passing L{str} to L{Headers.setRawHeaders} will encode the name as
ISO-8859-1 and values as UTF-8.
xr  re      xs   ☃Nro   rg   s   & r   test_rawHeadersValueEncoding0UnicodeHeadersTests.test_rawHeadersValueEncoding  sQ    
 I	h/0D)*.&0IJr   c                   V ^8  d   QhRR/# r   r   )r   s   "r   r   r     s     	I 	I4 	Ir   c                2   \        4       pVP                  RR4       V P                  VP                  R4      R.4       VP                  RR4       V P                  VP                  R4      RR.4       V P                  VP                  R4      RR.4       R# )rw   r.   lemurpandar   rx   ry   Nrz   rg   s   & r   r{   %UnicodeHeadersTests.test_addRawHeader  s~     I	vw'07)<	vw'07G2DE1Hh3GHr   c                   V ^8  d   QhRR/# r   r   )r   s   "r   r   r     s     ; ;T ;r   c                V    V P                  \        4       P                  R4      4       R# )r   r.   Nr   r(   s   &r   r   /UnicodeHeadersTests.test_getRawHeadersNoDefault  s    
 	')11&9:r   c                   V ^8  d   QhRR/# r   r   )r   s   "r   r   r     s     
 
 
r   c                F   \        4       p\        4       pV P                  VP                  RV4      V4       V P                  VP                  RR4      R4       V P	                  VP                  RR.4      R.4       V P	                  VP                  RR.4      R.4       R# )r   r.   Nr  )r   r   r   rS   r&   r   s   &  r   r   2UnicodeHeadersTests.test_getRawHeadersDefaultValue  s    
 I(Q__VW=wGQ__VT:DA$84&AOOF]O4O	
r   c                   V ^8  d   QhRR/# r   r   )r   s   "r   r   r     s     
E 
ED 
Er   c                    \        4       pR.pVP                  RV4       V P                  VP                  RV4      ^ ,          \        4       V P                  VP                  RV4      R.4       R# )z
If the object passed as the value list to L{Headers.setRawHeaders}
is later passed as a default to L{Headers.getRawHeaders}, the
result nevertheless contains decoded values.
r   r   keyr9   N)r   rP   r   rS   strr&   r   s   &  r   r   >UnicodeHeadersTests.test_getRawHeadersWithDefaultMatchingValue  s]     I*	(aooeW=a@#F87)Dr   c                   V ^8  d   QhRR/# r   r   )r   s   "r   r   r     s     
? 
?D 
?r   c                P   \        4       pVP                  RR.4       V P                  VP                  R4      R.4       V P                  VP                  R4      R.4       V P                  VP                  R4      R.4       V P                  VP                  R4      R.4       R# )r   r.   r'  r
  r   rx   r   Nr   rg   s   & r   r   &UnicodeHeadersTests.test_getRawHeaders  s    
 I		*07)<07)<1H:>1H:>r   c                   V ^8  d   QhRR/# r   r   )r   s   "r   r   r     s     
. 
.D 
.r   c                @   \        4       pVP                  RR.4       V P                  VP                  R4      4       V P                  VP                  R4      4       V P                  VP                  R4      4       V P                  VP                  R4      4       R# )r   r.   r'  r
  r   r   Nr   rg   s   & r   r   &UnicodeHeadersTests.test_hasHeaderTrue  so    
 I		*F+,F+,G,-G,-r   c                   V ^8  d   QhRR/# r   r   )r   s   "r   r   r     s     6 6T 6r   c                V    V P                  \        4       P                  R4      4       R# )r   r.   Nr   r(   s   &r   r   'UnicodeHeadersTests.test_hasHeaderFalse  s    
 	,,V45r   c                   V ^8  d   QhRR/# r   r   )r   s   "r   r   r     s     . .4 .r   c                *   \        4       pVP                  RR.4       V P                  VP                  R4      4       VP	                  R4       V P                  VP                  R4      4       V P                  VP                  R4      4       VP                  RR.4       V P                  VP                  R4      4       VP	                  R4       V P                  VP                  R4      4       V P                  VP                  R4      4       R# )	r   r   r'  re   r   r(  Barrd   Nr   rg   s   & r   r   %UnicodeHeadersTests.test_removeHeader  s     I	y)E*+	uU+,V,-	y)E*+	uU+,V,-r   c                   V ^8  d   QhRR/# r   r   )r   s   "r   r   r     r   r   c                    \        4       pVP                  R4       V P                  \        VP	                  4       4      . 4       R# )r   r.   Nr   rg   s   & r   r   0UnicodeHeadersTests.test_removeHeaderDoesntExist  s5    
 I	va0023R8r   c                   V ^8  d   QhRR/# r   r   )r   s   "r   r   r     s     
 
t 
r   c                   \        4       pVP                  RR.4       VP                  RR.4       VP                  RR.4       VP                  4        UUu0 uF  w  r#V\        V4      3kK  	  pppV P	                  V0 Rm4       R# u uppi )	r   r.   lemursr4   zbasic aksljdlk=r/   kjdfdfgdfgnsdN>   r   r   )s   kjdfdfgdfgnsdr   r   r   s   &    r   r   )UnicodeHeadersTests.test_getAllRawHeaders  s     I	
+	*->,?@	'89010B0B0DE0Dq%(m0D
E	
 Fs   Bc                   V ^8  d   QhRR/# r   r   )r   s   "r   r   r   -  s     , , ,r   c                2   \        4       pVP                  RR.4       \        4       pVP                  RR.4       \        4       pVP                  RRR.4       V P                  W4       V P                  W4       V P                  W4       \        4       pVP                  RR.4       \        4       pVP                  RR.4       \        4       pVP                  RRR.4       V P                  W4       V P                  W%4       V P                  W64       R# )r   r   r(  r'  re   ry   rx   Nr   )r)   r   r   r   
firstBytessecondBytes
thirdBytess   &      r   r   *UnicodeHeadersTests.test_headersComparison-  s    
 	EG9-UWI.	EGW#56&'E) Y
  (4i!!&8*5Y
  (G)<=+-+r   c                   V ^8  d   QhRR/# r   r   )r   s   "r   r   r   I  s     & &d &r   c                    \        4       pV P                  VR4       V P                  V\        4       4       V P                  VR4       R# )r   r   Nr   r   rg   s   & r   r   (UnicodeHeadersTests.test_otherComparisonI  s=    
 IAr"Avx(Au%r   c                   V ^8  d   QhRR/# r   r   )r   s   "r   r   r   S  s     
 
4 
r   c           
         RpRpRpRpRpRV,           pRV,           pV P                  \        \        WV./4      4      RP                  WEVP	                  R4      4      4       R	# )
z
The L{repr} of a L{Headers} instance shows the names and values of all
the headers it contains. This shows only reprs of bytes values, as
undecodable headers may cause an exception.
r      bar☃r   z'Foo'z'bar\xe2\x98\x83'bzHeaders({{{}: [{}, {!r}]}})utf8N)r&   r   r   r   r'   )r)   r   r   r   
fooEncoded
barEncodeds   &     r   r   UnicodeHeadersTests.test_reprS  so     
+
:%
:%
#Sz*+,)00

6(:	
r   c                   V ^8  d   QhRR/# r   r   )r   s   "r   r   r   g  s     
 
4 
r   c                    RpRpRpRpRp ! R R\         4      pV P                  \        V! WV./4      4      RV: R	V: R
VP                  R4      : R24       R# )r   r   rV  r   zb'Foo'zb'bar\xe2\x98\x83'c                      ] tR tRtRtR# );UnicodeHeadersTests.test_subclassRepr.<locals>.FunnyHeadersir  r   Nr   r   r   r   r   r_  r  r   r   r   r   r   r   rX  r   N)r   r&   r   r'   )r)   r   r   r   rY  rZ  r   s   &      r   r   %UnicodeHeadersTests.test_subclassReprg  sb    
 
,
	7 	 	s#J/01:szz&'9;	
r   c                   V ^8  d   QhRR/# r   r   )r   s   "r   r   r   {  s     Q Q4 Qr   c                D   \        4       pVP                  RR.4       VP                  4       pV P                  VP	                  R4      R.4       V P                  VP	                  R4      R.4       VP                  RR4       V P                  VP	                  R4      R.4       V P                  VP	                  R4      R.4       VP                  RR4       V P                  VP	                  R4      RR.4       V P                  VP	                  R4      RR.4       R	# )
r   r.   u   foo☃r   s   foo☃r   r
  r   rd   Nr   r   s   &  r   r   UnicodeHeadersTests.test_copy{  s     I	.FFH 	0;-@14F3GH 	
vu% 	0;-@14F3GH 	
vv& 	0;2FG14F3OPr   r   N)rC   rD   rE   rF   rG   r`   ri   rs   r  r  r  r#  r{   r   r   r   r   r   r   r   r   r   r   r   r   r   r   rH   r   r   r   r   r   N  s    N
:D "P ,"K	I;

E
?
.6.$9
,,8&
(
(Q Qr   r   c                  2    ] tR tRtRtR R ltR R ltRtR# )	MixedHeadersTestsi  za
Tests for L{Headers}, mixing L{bytes} and L{str} arguments for methods
where that is permitted.
c                   V ^8  d   QhRR/# r   r   )r   s   "r   r   MixedHeadersTests.__annotate__  s     	< 	<4 	<r   c                    \        4       pVP                  RR4       VP                  RR4       V P                  VP                  R4      R.4       V P                  VP                  R4      R.4       R# )z<
L{Headers.addRawHeader} accepts mixed L{str} and L{bytes}.
   bytesr3     Bytes   strStrrM   Nrz   rg   s   & r   r{   #MixedHeadersTests.test_addRawHeader  s]     I	x'	uh'2VH=/';r   c                   V ^8  d   QhRR/# r   r   )r   s   "r   r   rg    s     N ND Nr   c                   \        4       pVP                  RR.4       VP                  RR.4       VP                  RRR.4       VP                  RRR.4       V P                  VP                  R4      R.4       V P                  VP                  R4      R.4       V P                  VP                  R4      RR.4       V P                  VP                  R	4      R
R.4       R# )z=
L{Headers.setRawHeaders} accepts mixed L{str} and L{bytes}.
ri  r3  z	mixed-strs   mixed-bytesrj  rl  z	Mixed-StrrM   s   Mixed-Bytesrk  Nr   rg   s   & r   rs   $MixedHeadersTests.test_setRawHeaders  s     I	8*-	w'	h%67	(9:2XJ?/%957GH868:LMr   r   N)rC   rD   rE   rF   rG   r{   rs   rH   r   r   r   re  re    s    
	<N Nr   re  N)rG   
__future__r   typingr   twisted.trial.unittestr   r   twisted.web.http_headersr   r   r   twisted.web.test.requesthelperr	   r
   r   r   rY   r[   r   re  r   r   r   <module>rv     sj    #  @ M M 0
* 0
f IF`E `EFGQ( GQT
N Nr   