From aceffc56abb50d4fee745aacb1de552933ee8716 Mon Sep 17 00:00:00 2001 From: Matt Dunn-Rankin Date: Sat, 12 Jun 2021 02:23:18 -0700 Subject: [PATCH] Fix SWF downloading for HTTPS URLs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit TNT started using HTTPS URLs! And our old Ruby version (lol 😬) still requires explicit invocation to perform SSL during a request, so requests were failing! Now, we explicitly build the `Net::HTTPS` object, and turn on `use_ssl` if it's an HTTPS URL! (The shorthand invocation didn't seem to have an option for this, that I could find!) --- app/models/swf_asset.rb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/app/models/swf_asset.rb b/app/models/swf_asset.rb index 8c464f46..166cb9df 100644 --- a/app/models/swf_asset.rb +++ b/app/models/swf_asset.rb @@ -262,7 +262,9 @@ class SwfAsset < ActiveRecord::Base before_create do uri = URI.parse url begin - response = Net::HTTP.get_response(uri) + http = Net::HTTP.new(uri.host, uri.port) + http.use_ssl = (uri.scheme == 'https') + response = http.get(uri.request_uri) rescue Exception => e raise DownloadError, e.message end