@@ -202,9 +202,9 @@ def __init__(self, red):
202
202
if parsed_value != None :
203
203
self .red .parsed_hdrs [nn ] = parsed_value
204
204
205
- def setMessage (self , name , msg , ** vars ):
205
+ def setMessage (self , name , msg , ** kw ):
206
206
ident = 'header-%s' % name .lower ()
207
- self .red .setMessage (ident , msg , field_name = name , ** vars )
207
+ self .red .setMessage (ident , msg , field_name = name , ** kw )
208
208
209
209
@staticmethod
210
210
def _parseDate (values ):
@@ -254,7 +254,9 @@ def _splitString(instr, item, split):
254
254
"""
255
255
if not instr :
256
256
return []
257
- return [h .strip () for h in re .findall (r'%s(?=%s|\s*$)' % (item , split ), instr )]
257
+ return [h .strip () for h in re .findall (
258
+ r'%s(?=%s|\s*$)' % (item , split ), instr
259
+ )]
258
260
259
261
@GenericHeaderSyntax
260
262
def accept_ranges (self , name , values ):
@@ -341,8 +343,10 @@ def content_range(self, name, values):
341
343
return values
342
344
343
345
@GenericHeaderSyntax
344
- @CheckFieldSyntax (r'(?:%(TOKEN)s/%(TOKEN)s(?:\s*;\s*%(PARAMETER)s)*)' % globals (),
345
- rfc2616 % "sec-14.17" )
346
+ @CheckFieldSyntax (
347
+ r'(?:%(TOKEN)s/%(TOKEN)s(?:\s*;\s*%(PARAMETER)s)*)' % globals (),
348
+ rfc2616 % "sec-14.17"
349
+ )
346
350
@SingleFieldValue
347
351
def content_type (self , name , values ):
348
352
try :
@@ -421,12 +425,14 @@ def link(self, name, values):
421
425
# TODO: check syntax, values?
422
426
pass
423
427
424
- # The most common problem with Location is a non-absolute URI, so we separate
425
- # that from the syntax check.
428
+ # The most common problem with Location is a non-absolute URI,
429
+ # so we separate that from the syntax check.
426
430
@CheckFieldSyntax (URI_reference , rfc2616 % "sec-14.30" )
427
431
@SingleFieldValue
428
432
def location (self , name , values ):
429
- if self .red .res_status not in ["201" , "300" , "301" , "302" , "303" , "305" , "307" ]:
433
+ if self .red .res_status not in [
434
+ "201" , "300" , "301" , "302" , "303" , "305" , "307"
435
+ ]:
430
436
self .setMessage (name , rs .LOCATION_UNDEFINED )
431
437
if not re .match (r"^\s*%s\s*$" % URI , values [- 1 ], re .VERBOSE ):
432
438
self .setMessage (name , rs .LOCATION_NOT_ABSOLUTE ,
@@ -498,8 +504,10 @@ def vary(self, name, values):
498
504
return values
499
505
500
506
@GenericHeaderSyntax
501
- @CheckFieldSyntax (r'(?:%s/)?%s\s+[^,\s]+(?:\s+%s)?' % (TOKEN , TOKEN , COMMENT ),
502
- rfc2616 % "sec-14.45" )
507
+ @CheckFieldSyntax (
508
+ r'(?:%s/)?%s\s+[^,\s]+(?:\s+%s)?' % (TOKEN , TOKEN , COMMENT ),
509
+ rfc2616 % "sec-14.45"
510
+ )
503
511
def via (self , name , values ):
504
512
via_list = u"<ul>" + u"\n " .join (
505
513
[u"<li><code>%s</code></li>" % e (v ) for v in values ]
@@ -548,7 +556,10 @@ def x_meta_mssmarttagspreventparsing(self, name, values):
548
556
return values
549
557
550
558
@GenericHeaderSyntax
551
- @CheckFieldSyntax (PARAMETER , "http://msdn.microsoft.com/en-us/library/cc288325(VS.85).aspx" )
559
+ @CheckFieldSyntax (
560
+ PARAMETER ,
561
+ "http://msdn.microsoft.com/en-us/library/cc288325(VS.85).aspx"
562
+ )
552
563
def x_ua_compatible (self , name , values ):
553
564
directives = {}
554
565
for directive in values :
@@ -568,7 +579,9 @@ def x_ua_compatible(self, name, values):
568
579
569
580
@GenericHeaderSyntax
570
581
@SingleFieldValue
571
- @CheckFieldSyntax (r'(?:[10](?:\s*;\s*%(PARAMETER)s)*)' % globals (), 'http://blogs.msdn.com/b/ieinternals/archive/2011/01/31/controlling-the-internet-explorer-xss-filter-with-the-x-xss-protection-http-header.aspx' )
582
+ @CheckFieldSyntax (
583
+ r'(?:[10](?:\s*;\s*%(PARAMETER)s)*)' % globals (), 'http://blogs.msdn.com/b/ieinternals/archive/2011/01/31/controlling-the-internet-explorer-xss-filter-with-the-x-xss-protection-http-header.aspx'
584
+ )
572
585
def x_xss_protection (self , name , values ):
573
586
if int (values [- 1 ].split (';' , 1 )[0 ]) == 0 :
574
587
self .setMessage (name , rs .XSS_PROTECTION )
@@ -598,15 +611,15 @@ def __init__(self, red):
598
611
except AttributeError :
599
612
self .setMessage ('status' , rs .STATUS_NONSTANDARD )
600
613
601
- def setMessage (self , name , msg , ** vars ):
614
+ def setMessage (self , name , msg , ** kw ):
602
615
if name :
603
616
ident = 'status %s' % name
604
617
else :
605
618
ident = 'status'
606
619
self .red .setMessage (ident , msg ,
607
620
status = self .red .res_status ,
608
621
enc_status = e (self .red .res_status ),
609
- ** vars
622
+ ** kw
610
623
)
611
624
612
625
def status100 (self ): # Continue
@@ -621,7 +634,10 @@ def status200(self): # OK
621
634
pass
622
635
def status201 (self ): # Created
623
636
if self .red .method in nbhttp .safe_methods :
624
- self .setMessage ('status' , rs .CREATED_SAFE_METHOD , method = self .red .method )
637
+ self .setMessage ('status' ,
638
+ rs .CREATED_SAFE_METHOD ,
639
+ method = self .red .method
640
+ )
625
641
if not self .red .parsed_hdrs .has_key ('location' ):
626
642
self .setMessage ('header-location' , rs .CREATED_WITHOUT_LOCATION )
627
643
def status202 (self ): # Accepted
0 commit comments