public
Description: Ever wondered what HTTP requests the Ruby gem you are using to connect to a third party API is making? Use HTTP Spy to see what is going on behind the scenes
Homepage: http://github.com/martinbtt/net-http-spy
Clone URL: git://github.com/martinbtt/net-http-spy.git
Martin Sadler (author)
Sat Dec 05 09:29:15 -0800 2009
commit  73c30b3b28557e403da83edc3790b22f9e49f2e3
tree    927966b5fec3d660f9de5ea0879b7a0b9cf7a213
parent  5df645921a9accc99c2e276af16bdcc296627d0f
name age message
file Rakefile Fri Jun 05 13:29:09 -0700 2009 using Jeweler to generate gem [martinbtt]
file VERSION Sat Dec 05 09:29:11 -0800 2009 Version bump to 0.2.1 [Martin Sadler]
directory examples/ Sat Dec 05 04:39:55 -0800 2009 fix path to http spy in examples [Martin Sadler]
directory lib/ Fri Dec 04 09:17:42 -0800 2009 add options for limits to logging [Greg Weber]
file net-http-spy.gemspec Sat Dec 05 09:22:56 -0800 2009 Regenerated gemspec for version 0.2.1 [Martin Sadler]
file readme.markdown Thu May 07 10:59:00 -0700 2009 update readme [martinbtt]
directory spec/ Sat Dec 05 09:27:34 -0800 2009 use of webmock so that no live requests are mad... [Martin Sadler]
readme.markdown

About

Ever wondered what HTTP requests the Ruby gem you are using to connect to a third party API is making? Use HTTP Spy to see what is going on behind the scenes.

Installation

sudo gem install martinbtt-net-http-spy

Example Usage

require 'rubygems'
require 'twitter'
gem 'net-http-spy'
require 'net-http-spy'

Twitter::Search.new('httparty').each { |r| r }
# Outputs...
-- : CONNECT: ["search.twitter.com", 80]
-- : GET /search.json?q=httparty
-- : BODY: Net::HTTPOK

See the examples folder for more.

Further Options

Show the call trace to the originating line of code in the third party gem

Net::HTTP.http_logger_options = {:trace => true}

Output the body of the request

Net::HTTP.http_logger_options = {:body => true}

Show the full raw HTTP output

Net::HTTP.http_logger_options = {:verbose => true}

Change the logger. By default HTTP spy logs to STDOUT

Net::HTTP.http_logger = Logger.new('twitter.log')

Bonus Points

Use it to grab sample data for FakeWeb = testing goodness.

Notes

This is a pretty early release. I'm sure there is plenty that can be done to improve compatibility as several libraries call Net::HTTP in a slightly different way. Feel free to fork and send in pull requests/patches.

Find Me

Martin Sadler (martin -- at -- beyondthetype.com)

  • Blog: http://www.beyondthetype.com
  • Follow: http://twitter.com/martinbtt
  • Code: http://github.com/martinbtt
  • Recommend: http://www.workingwithrails.com/person/5152-martin-sadler