Sha256: 96079c16ef88652c1c3333a3cfa64f8e67c7857b89b62a9da9a341e50918b29f

Contents?: true

Size: 714 Bytes

Versions: 105

Compression:

Stored size: 714 Bytes

Contents

require 'ostruct'

module HttpRequestTestHelper
  def http_request(method, uri, options = {})
    begin
      uri = URI.parse(uri)
    rescue
      uri = Addressable::URI.heuristic_parse(uri)
    end
    response = nil
    clazz = ::Net::HTTP.const_get("#{method.to_s.capitalize}")
    req = clazz.new("#{uri.path}#{uri.query ? '?' : ''}#{uri.query}", options[:headers])
    req.basic_auth uri.user, uri.password if uri.user
    http = ::Net::HTTP.new(uri.host, uri.port)
    http.use_ssl = true if uri.scheme == "https"
    response = http.start {|http|
      http.request(req, options[:body])
    }
    OpenStruct.new({
      body: response.body,
      headers: response,
      status: response.code })
  end
end

Version data entries

105 entries across 99 versions & 8 rubygems

Version Path
fluent-plugin-google-cloud-logging-on-prem-0.1.0 vendor/ruby/3.1.0/gems/webmock-3.18.1/test/http_request.rb
webmock-3.18.1 test/http_request.rb
webmock-3.18.0 test/http_request.rb
webmock-3.15.2 test/http_request.rb
webmock-3.16.2 test/http_request.rb
webmock-3.16.1 test/http_request.rb
webmock-3.15.1 test/http_request.rb
webmock-3.17.1 test/http_request.rb
webmock-3.17.0 test/http_request.rb
logstash-output-scalyr-0.2.1.beta vendor/bundle/jruby/2.5.0/gems/webmock-3.13.0/test/http_request.rb
logstash-output-scalyr-0.2.0 vendor/bundle/jruby/2.5.0/gems/webmock-3.13.0/test/http_request.rb
logstash-output-scalyr-0.2.0.beta vendor/bundle/jruby/2.5.0/gems/webmock-3.13.0/test/http_request.rb
logstash-output-scalyr-0.1.26.beta vendor/bundle/jruby/2.5.0/gems/webmock-3.13.0/test/http_request.rb
logstash-output-scalyr-0.1.25.beta vendor/bundle/jruby/2.5.0/gems/webmock-3.13.0/test/http_request.rb
logstash-output-scalyr-0.1.24.beta vendor/bundle/jruby/2.5.0/gems/webmock-3.13.0/test/http_request.rb
logstash-output-scalyr-0.1.23.beta vendor/bundle/jruby/2.5.0/gems/webmock-3.13.0/test/http_request.rb
logstash-output-scalyr-0.1.22.beta vendor/bundle/jruby/2.5.0/gems/webmock-3.13.0/test/http_request.rb
logstash-output-scalyr-0.1.21.beta vendor/bundle/jruby/2.5.0/gems/webmock-3.13.0/test/http_request.rb
logstash-output-scalyr-0.1.20.beta vendor/bundle/jruby/2.5.0/gems/webmock-3.13.0/test/http_request.rb
webmock-3.14.0 test/http_request.rb