Skip to content

Instantly share code, notes, and snippets.

@vangberg
Created December 14, 2010 20:10
Show Gist options
  • Save vangberg/741008 to your computer and use it in GitHub Desktop.
Save vangberg/741008 to your computer and use it in GitHub Desktop.
persistent http w/ ruby
require "curb"
# Persistent.
c = Curl::Easy.new
c.url = "http://127.0.0.1"
2.times { c.perform }
# Not persistent.
2.times {
c = Curl::Easy.new
c.url = "http://127.0.0.1"
c.perform
}
require "httpclient"
# Persistent.
client = HTTPClient.new
2.times { client.get("http://127.0.0.1") }
# Not persistent.
2.times {
client = HTTPClient.new
client.get("http://127.0.0.1")
}
require "uri"
require "net/http/persistent"
uri = URI.parse "http://127.0.0.1"
# Persistent.
per = Net::HTTP::Persistent.new
get = Net::HTTP::Get.new(uri.request_uri)
2.times { per.request uri, get }
# Persistent.
2.times {
per = Net::HTTP::Persistent.new
get = Net::HTTP::Get.new(uri.request_uri)
per.request uri, get
}
# DUDE! It's "net-http-persistent" - of course it's persistent. Wtf, c'mon.
require "typhoeus"
# Persistent.
Typhoeus::Request.get("http://127.0.0.1")
Typhoeus::Request.get("http://127.0.0.1")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment