Fix SWF downloading for HTTPS URLs

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!)
This commit is contained in:
Emi Matchu 2021-06-12 02:23:18 -07:00 committed by GitHub
parent 8d29f50392
commit aceffc56ab
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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