Skip to content

Instantly share code, notes, and snippets.

@phiggins
Created October 4, 2010 05:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save phiggins/609286 to your computer and use it in GitHub Desktop.
Save phiggins/609286 to your computer and use it in GitHub Desktop.
# The many ways to use curb to do http requests.
#
# These all share code, but are different code paths.
require 'curb'
url = "http://www.example.com"
c = Curl::Easy.new(url)
c.url = url
c.http_get
p c.body_str.size ; p c.response_code
c = Curl::Easy.new(url)
c.url = url
c.http("GET")
p c.body_str.size ; p c.response_code
c = Curl::Easy.new(url)
c.url = url
c.perform
p c.body_str.size ; p c.response_code
c = Curl::Easy.http_get(url)
p c.body_str.size ; p c.response_code
c = Curl::Easy.perform(url)
p c.body_str.size ; p c.response_code
# Output:
# 596
# 200
# 596
# 200
# 596
# 200
# 596
# 200
# 596
# 200
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment