Sha256: e754532ccbb04baff315009240837f6b19a0202963d0a3ba2ea6092943b40fe1
Contents?: true
Size: 833 Bytes
Versions: 2
Compression:
Stored size: 833 Bytes
Contents
require 'net/http' require 'benchmark' module Chicanery class Site attr_reader :name, :uri, :options, :body, :code, :duration def initialize name, url, options={} @name, @uri, @options = name, URI(url), options end def get req = Net::HTTP::Get.new uri.path req.basic_auth options[:user], options[:password] if options[:user] and options[:password] http_opts = { use_ssl: uri.scheme == 'https' } http_opts[:verify_mode] = OpenSSL::SSL::VERIFY_NONE unless options[:verify_ssl] start = Time.now res = Net::HTTP.start uri.host, uri.port, http_opts do |https| https.request req end @duration, @code, @body = (Time.now - start), res.code, res.body res.value #check for success via a spectactularly poorly named method res.body end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
chicanery-0.1.3 | lib/chicanery/site.rb |
chicanery-0.1.1 | lib/chicanery/site.rb |