7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
|
# File 'lib/rack/fastlint.rb', line 7
def self.fastlint res
begin
return false unless res.respond_to?(:to_a) && res.count == 3
status, , body = res.to_a
return false if status.nil?
return false if .nil?
return false if body.nil?
return false unless status.to_i >= 100 || status.to_i == -1
return false unless .respond_to? :each
return false unless body.respond_to? :each
return false if body.respond_to?(:to_path) && !File.exist?(body.to_path)
if status.to_i < 200 || [204, 205, 304].include?(status.to_i)
return false if .member? "Content-Length"
return false if .member? "Content-Type"
end
.each { |k,v|
next if k.start_with? "rack."
return false unless k.kind_of? String
return false unless v.kind_of? String
return false if k == "Status"
return false unless k !~ /[:\n]/
return false unless k !~ /[-_]\z/
return false unless k =~ /\A[a-zA-Z][a-zA-Z0-9_-]*\z/
}
body.each { |p| return false unless p.respond_to? :to_str } true
rescue => e
false
end
end
|