class Rack::BlockYundun
Public Class Methods
new(app)
click to toggle source
# File lib/rack/block_yundun.rb, line 3 def initialize(app) @app = app end
Public Instance Methods
call(env)
click to toggle source
# File lib/rack/block_yundun.rb, line 7 def call(env) if match_yundun?(env) [406, {}, [not_acceptable_rfc_message]] else @app.call(env) end end
Private Instance Methods
match_yundun?(env)
click to toggle source
# File lib/rack/block_yundun.rb, line 16 def match_yundun?(env) keywords = %w[Alibaba Security Heimdall] keywords.any? {|keyword| env['HTTP_USER_AGENT'].include?(keyword)} end
not_acceptable_rfc_message()
click to toggle source
# File lib/rack/block_yundun.rb, line 22 def not_acceptable_rfc_message <<-MESSAGE The target resource does not have a current representation that would be acceptable to the user agent, according to the proactive negotiation header fields received in the request1, and the server is unwilling to supply a default representation. MESSAGE end