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
|
# File 'lib/rack/fastlint.rb', line 7
def self.response res
return false unless res.kind_of?(Array) && res.count == 3
status, , body = res
return false unless status.to_i >= 100 || status.to_i == -1
return false unless .respond_to? :each
return false unless body.respond_to? :each
if body.respond_to? :to_path
return false unless File.exist? body.to_path
end
begin
.each { |k,v|
next if key =~ /^rack\..+$/
throw StandardError unless k.kind_of? String
throw StandardError unless v.kind_of? String
throw StandardError if k.downcase == "status"
throw StandardError unless k !~ /[:\n]/
throw StandardError unless k !~ /[-_]\z/
throw StandardError unless k =~ /\A[a-zA-Z][a-zA-Z0-9_-]*\z/
}
body.each { |part| throw StandardError unless part.kind_of? String }
rescue StandardError
return false
end
true
end
|