1
0
Fork 0
mirror of https://github.com/puma/puma.git synced 2022-11-09 13:48:40 -05:00
puma--puma/test/testhelp.rb

39 lines
837 B
Ruby
Raw Normal View History

2011-09-23 23:46:33 -04:00
# Copyright (c) 2011 Evan Phoenix
# Copyright (c) 2005 Zed A. Shaw
%w(lib test).each do |d|
dir = File.expand_path("../../#{d}", __FILE__)
$LOAD_PATH.unshift dir unless $LOAD_PATH.include?(dir)
end
require 'rubygems'
require 'test/unit'
require 'net/http'
require 'digest/sha1'
require 'uri'
require 'stringio'
2011-09-22 22:24:43 -04:00
require 'puma'
# Either takes a string to do a get request against, or a tuple of [URI, HTTP] where
# HTTP is some kind of Net::HTTP request object (POST, HEAD, etc.)
def hit(uris)
results = []
uris.each do |u|
res = nil
if u.kind_of? String
res = Net::HTTP.get(URI.parse(u))
else
url = URI.parse(u[0])
res = Net::HTTP.new(url.host, url.port).start {|h| h.request(u[1]) }
end
assert res != nil, "Didn't get a response: #{u}"
results << res
end
return results
end