Spying on Ruby’s Net::HTTP

by john on August 4, 2011

I’ve heard two people complain that they can’t see OAuth HTTP behavior and get unexpected 401s. If you want to see what’s going on at the transport level, here’s a monkeypatch (depends on ActiveSupport for the alias_method_chain) just for you:


class Net::HTTP

  def initialize_with_debug(*args, &block)
    initialize_without_debug(*args, &block)
    set_debug_output $stderr
  end

  alias_method_chain :initialize, :debug
end

Leave a Comment

Previous post: Ruby’s Hash#default=

Next post: Best way to test Ruby class methods?