Wire Level Debug for ActiveResource

Posted by dave
on February 13, 2007 @ 08:08 AM

ActiveResource provides the mechanism to implement RESTful Ruby clients in Rails 1.2. If you want to see wire level debug output from the Net::HTTP layer you can enable it by editing:


[activeresource]/lib/activeresource/connection.rb

Add the set_debug_output line to the (private) http method.

1
2
3
4
5
6
7
8
9
10
11
12

     def http
        unless @http
          @http             = Net::HTTP.new(@site.host, @site.port)
          @http.use_ssl     = @site.is_a?(URI::HTTPS)
          @http.verify_mode = OpenSSL::SSL::VERIFY_NONE if @http.use_ssl
          # enable debug http wirelevel dumps
          @http.set_debug_output $stderr
        end

        @http
      end
Very handy for debugging ActiveResource with a Rails console.