Created
May 17, 2017 10:07
-
-
Save cfitz/c97bc3b9533a3e8686e54b89081df1dd to your computer and use it in GitHub Desktop.
Use HTTPS if post is set to 443/8443
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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