Class: Tire::HTTP::Client::Curb
- Inherits:
-
Object
- Object
- Tire::HTTP::Client::Curb
- Defined in:
- lib/tire/http/clients/curb.rb
Class Method Summary collapse
- .client ⇒ Object
- .delete(url) ⇒ Object
- .get(url, data = nil) ⇒ Object
- .head(url) ⇒ Object
- .post(url, data) ⇒ Object
- .put(url, data) ⇒ Object
Class Method Details
.client ⇒ Object
10 11 12 13 14 15 16 17 |
# File 'lib/tire/http/clients/curb.rb', line 10 def self.client Thread.current[:client] ||= begin client = ::Curl::Easy.new client.resolve_mode = :ipv4 # client.verbose = true client end end |
.delete(url) ⇒ Object
47 48 49 50 51 |
# File 'lib/tire/http/clients/curb.rb', line 47 def self.delete(url) client.url = url client.http_delete Response.new client.body_str, client.response_code end |
.get(url, data = nil) ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/tire/http/clients/curb.rb', line 19 def self.get(url, data=nil) client.url = url # FIXME: Curb cannot post bodies with GET requests? # Roy Fielding seems to approve: # <http://tech.groups.yahoo.com/group/rest-discuss/message/9962> if data client.post_body = data client.http_post else client.http_get end Response.new client.body_str, client.response_code end |
.head(url) ⇒ Object
53 54 55 56 57 |
# File 'lib/tire/http/clients/curb.rb', line 53 def self.head(url) client.url = url client.http_head Response.new client.body_str, client.response_code end |
.post(url, data) ⇒ Object
34 35 36 37 38 39 |
# File 'lib/tire/http/clients/curb.rb', line 34 def self.post(url, data) client.url = url client.post_body = data client.http_post Response.new client.body_str, client.response_code end |
.put(url, data) ⇒ Object
41 42 43 44 45 |
# File 'lib/tire/http/clients/curb.rb', line 41 def self.put(url, data) client.url = url client.http_put data Response.new client.body_str, client.response_code end |