class Qeweney::RackRequestAdapter
def finish(req)
def finish(req) end
def initialize(env)
def initialize(env) @env = env @response_headers = {} @response_body = [] end
def rack_response
def rack_response @status = @response_headers.delete(':status') [ @status, @response_headers, @response_body ] end
def request_headers
def request_headers request_http_headers.merge( ':scheme' => @env['rack.url_scheme'], ':method' => @env['REQUEST_METHOD'].downcase, ':path' => request_path_from_env ) end
def request_http_headers
def request_http_headers headers = {} @env.each do |k, v| next unless k =~ /^HTTP_(.+)$/ headers[Regexp.last_match(1).downcase.gsub('_', '-')] = v end headers end
def request_path_from_env
def request_path_from_env path = File.join(@env['SCRIPT_NAME'], @env['PATH_INFO']) path = path + "?#{@env['QUERY_STRING']}" if @env['QUERY_STRING'] path end
def respond(req, body, headers)
def respond(req, body, headers) @response_body << body @response_headers = headers end
def send_chunk(req, body, done: false)
def send_chunk(req, body, done: false) @response_body << body end
def send_headers(req, headers, empty_response: nil)
def send_headers(req, headers, empty_response: nil) @response_headers = headers end