Class: Tap::Mechanize::Test::EchoServer

Inherits:
Object
  • Object
show all
Defined in:
lib/tap/mechanize/test/echo_server.rb

Overview

EchoServer is a Rack application that simply echos back the request environment. The response is:

[200, {request headers}, [request body]]

Class Method Summary collapse

Class Method Details

.call(env) ⇒ Object



10
11
12
13
14
15
16
# File 'lib/tap/mechanize/test/echo_server.rb', line 10

def self.call(env)
  body = env['rack.input'].read
  headers = {}
  env.each_pair {|key, value| headers[key] = value unless key =~ /^rack/ }
  
  [200, headers, [body]]
end