Is there a reason not to have this in its own file?  If not, I would request you do that, as well as split out a commit for the net::http and ar::connection extensions.  As a follow-on, it would be really nice to see these as pull requests to those 2 upstream projects as well. They may not want it, but it would be nice to at least try to push this upstream.  I am sure you'd need a test or two, but hopefully not that much additional work.