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