From fdbb858bf7112068fa30a027e7b7adce6d8b046e Mon Sep 17 00:00:00 2001 From: Laura Paakkinen Date: Thu, 5 Jan 2023 13:39:20 +0000 Subject: [PATCH] Fix #280 cannot pass headers to net http on ruby 2 --- lib/premailer/rails/css_loaders/network_loader.rb | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/premailer/rails/css_loaders/network_loader.rb b/lib/premailer/rails/css_loaders/network_loader.rb index 2ffa9e9..ada8269 100644 --- a/lib/premailer/rails/css_loaders/network_loader.rb +++ b/lib/premailer/rails/css_loaders/network_loader.rb @@ -6,7 +6,11 @@ module NetworkLoader def load(url) uri = uri_for_url(url) - Net::HTTP.get(uri, { 'Accept' => 'text/css' }) if uri + if Gem::Version.new(RUBY_VERSION) >= Gem::Version.new("3.0.0") + Net::HTTP.get(uri, { 'Accept' => 'text/css' }) if uri + else + Net::HTTP.get(uri) if uri + end end def uri_for_url(url)