8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
|
# File 'lib/webmock/server/handler.rb', line 8
def call(env)
uri = stub_uri
uri.path = env['PATH_INFO']
uri.query = env['QUERY_STRING']
request = case env['REQUEST_METHOD']
when 'GET'
Net::HTTP::Get.new uri
when 'POST'
Net::HTTP::Post.new uri
else
nil
end
request.body = env['rack.input'].gets if env['rack.input']
request['CONTENT_TYPE'] = env['CONTENT_TYPE']
response = Net::HTTP.new(uri.host, uri.port).request(request)
= Hash[response.to_hash.map { |k,v| [k, v[0]] }]
[ response.code, , [ response.body ]]
end
|