Sha256: 972ee935ecb1a7b69f587f59b6df6b4efa229dd7cae6925448c5c4167164a59b
Contents?: true
Size: 744 Bytes
Versions: 1
Compression:
Stored size: 744 Bytes
Contents
require 'open-uri' require 'openssl' module TerraformDevKit class Request def initialize(url, query_strings: [], headers: {}) @url = url @query_strings = query_strings @headers = headers end def execute(raise_on_codes: []) url = URI.parse(@url) url.query = URI.encode_www_form(@query_strings) unless @query_strings.empty? puts "Fetching #{url}" options = { redirect: false, ssl_verify_mode: OpenSSL::SSL::VERIFY_NONE } options.merge!(@headers) URI.open(url, options) rescue OpenURI::HTTPError => error response = error.io raise if raise_on_codes.include?(response.status[0]) response end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
TerraformDevKit-0.4.0 | lib/TerraformDevKit/request.rb |