Sha256: fee838ed572c917fea27fee6c80e91500a17d149256f4561b1f71186f3a169fd
Contents?: true
Size: 740 Bytes
Versions: 20
Compression:
Stored size: 740 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) 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
20 entries across 20 versions & 1 rubygems