-
-
Save simonoff/a42ea72c5b978669de6a9afb25cdaf67 to your computer and use it in GitHub Desktop.
Enable debug for all Ruby HTTP requests
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' | |
module Net | |
class HTTP | |
def self.enable_debug! | |
class << self | |
alias_method :__new__, :new | |
def new(*args, &blk) | |
instance = __new__(*args, &blk) | |
instance.set_debug_output($stderr) | |
instance | |
end | |
end | |
end | |
def self.disable_debug! | |
class << self | |
alias_method :new, :__new__ | |
remove_method :__new__ | |
end | |
end | |
end | |
end | |
# Net::HTTP.enable_debug! | |
# Net::HTTP.disable_debug! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment