I'm doing a lot of work lately using ActiveResource. I wanted to get 'down to the wire' and see the traffic flowing over http... so a quick google search, and I found an entry I had written in 2008. I love it when that happens! So I'm reblogging it with a slight change to make it work in Ruby 1.9.
If you're using rails, create an initializer name active_resource_spy.rb and drop in this content:
class ActiveResource::Connection
# Creates new Net::HTTP instance for communication with
# remote service and resources.
def 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?
http.read_timeout = @timeout if @timeout
#Here's the addition that allows you to see the output
http.set_debug_output $stderr
return http
end
end
All the data that flows over the http connection will be dumped to $stderr (the terminal you started the app in, unless you redirected it).