def run( request, response, &block )
ck_req = CGIKit::Request.new(@headers, @params)
if block_given?
ck_res = block.call(ck_req)
end
ap_req = Apache.request
table = ap_req.headers_out
ck_res.header.scan(/([^:]+): (.+)#{EOL}/n){ |name, value|
case name
when 'Set-Cookie'
table.add(name, value)
when /^status$/ni
ap_req.status_line = value
ap_req.status = value.to_i
when /^content-type$/ni
ap_req.content_type = value
when /^content-encoding$/ni
ap_req.content_encoding = value
when /^location$/ni
if ap_req.status == 200
ap_req.status = 302
end
ap_req.headers_out[name] = value
else
ap_req.headers_out[name] = value
end
}
ap_req.send_http_header
ap_req.write(ck_res.to_s)
end