Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Tree: 9dbf915e18
Fetching contributors…

Cannot retrieve contributors at this time

40 lines (34 sloc) 1.294 kB
module Rack
class Rewrite
class ConditionSet
attr_reader :parent_set, :actions, :conditions
def initialize(parent_set, conditions = nil)
@parent_set = parent_set
@conditions = conditions
@actions = []
end
def satisfied?(env)
if conditions
uri_ok = conditions.key?(:path_info) ? conditions[:path_info] === env['PATH_INFO'] : true
method_ok = conditions.key?(:method) ? conditions[:method] === env['REQUEST_METHOD'].downcase : true
host_ok = conditions.key?(:host) ? conditions[:host] === env['HTTP_HOST'] : true
port_ok = conditions.key?(:port) ? conditions[:port] === env['SERVER_PORT'].to_i : true
scheme_ok = conditions.key?(:scheme) ? conditions[:scheme] === env['rack.url_scheme'] : true
if conditions.key?(:params)
req = Rack::Request.new(env)
params_ok = true
conditions[:params].each do |key, test|
params_ok = test === req.params[key.to_s]
break unless params_ok
end
else
params_ok = true
end
uri_ok && method_ok && host_ok && port_ok && scheme_ok && params_ok
else
true
end
end
end
end
end
Jump to Line
Something went wrong with that request. Please try again.