Created
October 4, 2010 05:43
-
-
Save phiggins/609286 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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