402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
|
# File 'lib/rack/lint.rb', line 402
def ()
assert("headers object should respond to #each, but doesn't (got #{.class} as headers)") {
.respond_to? :each
}
.each { |key, value|
assert("header key must be a string, was #{key.class}") {
key.instance_of? String
}
assert("header must not contain Status") { key.downcase != "status" }
assert("header names must not contain : or \\n") { key !~ /[:\n]/ }
assert("header names must not end in - or _") { key !~ /[-_]\z/ }
assert("invalid header name: #{key}") { key =~ /\A[a-zA-Z][a-zA-Z0-9_-]*\z/ }
assert("a header value must be a String, but the value of " +
"'#{key}' is a #{value.class}") { value.kind_of? String }
value.split("\n").each { |item|
assert("invalid header value #{key}: #{item.inspect}") {
item !~ /[\000-\037]/
}
}
}
end
|