<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Hungry Machine &#187; ruby http activeresource</title>
	<atom:link href="http://blog.hungrymachine.com/tag/ruby-http-activeresource/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.hungrymachine.com</link>
	<description>The guys behind LivingSocial</description>
	<lastBuildDate>Sun, 25 Oct 2009 15:08:39 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Curb your Net::HTTP</title>
		<link>http://blog.hungrymachine.com/2008/04/08/an-alternative-to-net-http/</link>
		<comments>http://blog.hungrymachine.com/2008/04/08/an-alternative-to-net-http/#comments</comments>
		<pubDate>Tue, 08 Apr 2008 18:21:00 +0000</pubDate>
		<dc:creator>aaron</dc:creator>
				<category><![CDATA[All]]></category>
		<category><![CDATA[Rails]]></category>
		<category><![CDATA[ruby http activeresource]]></category>

		<guid isPermaLink="false">blog.hungrymachine.com/2008/11/13/an-alternative-to-net-http</guid>
		<description><![CDATA[
Curb is a ruby binding for libcurl. We&#8217;ve had sporadic issues with Net::HTTP, which this might aleviate via native dns, native timeouts, performance improvements, etc.   It wouldnt be hard to re-implement ActiveResource, rfacebook, myspace-ruby, etc to use it instead. Anyone using this already? 

sudo gem install curb




require 'rubygems'
require 'curb'
require &#34;net/http&#34;
require 'benchmark'

iterations = 40
Benchmark.bm [...]]]></description>
			<content:encoded><![CDATA[<p><img style="float:left;padding:0px 12px 12px 12px" src="http://farm1.static.flickr.com/127/373875465_3134e00927_m.jpg"></p>
<p><a href="http://curb.rubyforge.org/">Curb</a> is a ruby binding for <a href="http://curl.haxx.se/">libcurl</a>. We&#8217;ve had sporadic issues with Net::HTTP, which this might aleviate via native dns, native timeouts, performance improvements, etc.   It wouldnt be hard to re-implement ActiveResource, rfacebook, myspace-ruby, etc to use it instead. Anyone using this already? </p>
<pre>
sudo gem install curb
</pre>
<div style="clear:both"></div>
<div class="CodeRay">
<div class="code">
<pre>require <span style="background-color:#fff0f0"><span style="color:#710">'</span><span style="color:#D20">rubygems</span><span style="color:#710">'</span></span>
require <span style="background-color:#fff0f0"><span style="color:#710">'</span><span style="color:#D20">curb</span><span style="color:#710">'</span></span>
require <span style="background-color:#fff0f0"><span style="color:#710">&quot;</span><span style="color:#D20">net/http</span><span style="color:#710">&quot;</span></span>
require <span style="background-color:#fff0f0"><span style="color:#710">'</span><span style="color:#D20">benchmark</span><span style="color:#710">'</span></span>

iterations = <span style="color:#00D; font-weight:bold">40</span>
<span style="color:#036; font-weight:bold">Benchmark</span>.bm <span style="color:#080; font-weight:bold">do</span> |x|
  x.report(<span style="background-color:#fff0f0"><span style="color:#710">&quot;</span><span style="color:#D20">curb</span><span style="color:#710">&quot;</span></span>) <span style="color:#080; font-weight:bold">do</span>
    iterations.times <span style="color:#080; font-weight:bold">do</span>
      c = <span style="color:#036; font-weight:bold">Curl</span>::<span style="color:#036; font-weight:bold">Easy</span>.perform(<span style="background-color:#fff0f0"><span style="color:#710">&quot;</span><span style="color:#D20">http://www.google.com</span><span style="color:#710">&quot;</span></span>)
      <span style="color:#888">#puts c.body_str</span>
    <span style="color:#080; font-weight:bold">end</span>
  <span style="color:#080; font-weight:bold">end</span>
  x.report(<span style="background-color:#fff0f0"><span style="color:#710">&quot;</span><span style="color:#D20">net/http</span><span style="color:#710">&quot;</span></span>)  <span style="color:#080; font-weight:bold">do</span>
    iterations.times <span style="color:#080; font-weight:bold">do</span>
      http = <span style="color:#036; font-weight:bold">Net</span>::<span style="color:#036; font-weight:bold">HTTP</span>.start(<span style="background-color:#fff0f0"><span style="color:#710">&quot;</span><span style="color:#D20">www.google.com</span><span style="color:#710">&quot;</span></span>)
      req = <span style="color:#036; font-weight:bold">Net</span>::<span style="color:#036; font-weight:bold">HTTP</span>::<span style="color:#036; font-weight:bold">Get</span>.new(<span style="background-color:#fff0f0"><span style="color:#710">&quot;</span><span style="color:#D20">/</span><span style="color:#710">&quot;</span></span>)
      res = http.request(req)
      <span style="color:#888">#puts res.body</span>
    <span style="color:#080; font-weight:bold">end</span>
  <span style="color:#080; font-weight:bold">end</span>
<span style="color:#080; font-weight:bold">end</span></pre>
</div>
</div>
<pre>
             user     system      total        real
curb      0.010000   0.030000   0.040000 (  4.019197)
net/http  0.140000   0.110000   0.250000 (  4.155106)
</pre>
]]></content:encoded>
			<wfw:commentRss>http://blog.hungrymachine.com/2008/04/08/an-alternative-to-net-http/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
