Module: Icarus::Mod::Tools::Sync::Helpers
- Included in:
- CLI::Remove, ModinfoList, Mods, ToolinfoList, Tools
- Defined in:
- lib/icarus/mod/tools/sync/helpers.rb
Overview
Sync helper methods
Instance Method Summary collapse
Instance Method Details
#retrieve_from_url(url) ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/icarus/mod/tools/sync/helpers.rb', line 16 def retrieve_from_url(url) raise RequestFailed, "Invalid URI: '#{url}'" unless url && url =~ URI::DEFAULT_PARSER.make_regexp uri = URI(url) http = Net::HTTP.new(uri.host, uri.port) if uri.scheme == "https" http.use_ssl = true http.verify_mode = OpenSSL::SSL::VERIFY_PEER # Disable CRL checking which is causing the issue http.verify_callback = proc { |preverify_ok, ssl_context| if ssl_context.error == OpenSSL::X509::V_ERR_UNABLE_TO_GET_CRL true else preverify_ok end } end res = http.get(uri.path.empty? ? "/" : uri.path) raise RequestFailed, "HTTP Request failed for #{url} (#{res.code}): #{res.}" unless res&.code == "200" JSON.parse(res.body, symbolize_names: true) end |