Permalink
Switch branches/tags
Nothing to show
Find file
Fetching contributors…
Cannot retrieve contributors at this time
31 lines (26 sloc) 863 Bytes
require 'net/http'
require 'net/https'
##
# Thanks to {Mike Mondragon}[http://www.mondragon.cc/] for providing the
# following snippet.
#
# patch Net::HTTP so un caged requests don't go over the wire
module Net #:nodoc:
class HTTP #:nodoc:
alias :old_net_http_request :request
alias :old_net_http_connect :connect
def request(req, body = nil, &block)
prot = use_ssl ? "https" : "http"
uri_cls = use_ssl ? URI::HTTPS : URI::HTTP
query = req.path.split('?',2)
opts = {:host => self.address,
:port => self.port, :path => query[0]}
opts[:query] = query[1] if query[1]
uri = uri_cls.build(opts)
raise ArgumentError.new("#{req.method} method to #{uri} not being handled in testing")
end
def connect
raise ArgumentError.new("connect not being handled in testing")
end
end
end