Skip to content

Instantly share code, notes, and snippets.

@cfitz
Created May 17, 2017 10:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cfitz/c97bc3b9533a3e8686e54b89081df1dd to your computer and use it in GitHub Desktop.
Save cfitz/c97bc3b9533a3e8686e54b89081df1dd to your computer and use it in GitHub Desktop.
Use HTTPS if post is set to 443/8443
require 'net/http'
class Net::HTTP
singleton_class.send(:alias_method, :start_orig, :start)
class << self
def start(address, *arg, &block)
opt = Hash.try_convert(arg[-1]) ? arg.pop : {}
opt[:use_ssl] = ( [ 443, 8443 ].include?(arg.first) )
arg << opt
start_orig(address, *arg, &block )
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment