Rather than complaining about a missing use_ssl= method, if net/https
fails to load we define a mock use_ssl= method that raises a runtime
error making the LoadError message public. This is not the most
user-friendly message (we would prefer not to expose internals), but
it should be clear enough to help owners that forget to read the log
find what's missing.
begin
require 'net/https'
rescue LoadError => e
begin
require 'net/https'
rescue LoadError => e
- error "Couldn't load 'net/https': #{e.pretty_inspect}"
+ error "Couldn't load 'net/https': #{e}"
error "Secured HTTP connections will fail"
error "Secured HTTP connections will fail"
+ # give a nicer error than "undefined method `use_ssl='"
+ ::Net::HTTP.class_eval <<-EOC
+ define_method :use_ssl= do |val|
+ # does anybody really set it to false?
+ break if !val
+ raise _("I can't do secure HTTP, sorry (%{msg})") % {
+ :msg => e.message
+ }
+ end
+ EOC
end
# To handle Gzipped pages
end
# To handle Gzipped pages