Class: Tire::HTTP::Client::Curb

Inherits:
Object
  • Object
show all
Defined in:
lib/tire/http/clients/curb.rb

Class Method Summary collapse

Class Method Details

.delete(url) ⇒ Object



44
45
46
47
48
# File 'lib/tire/http/clients/curb.rb', line 44

def self.delete(url)
  @client.url = url
  @client.http_delete
  Response.new @client.body_str, @client.response_code
end

.get(url, data = nil) ⇒ Object



16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/tire/http/clients/curb.rb', line 16

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



50
51
52
53
54
# File 'lib/tire/http/clients/curb.rb', line 50

def self.head(url)
  @client.url = url
  @client.http_head
  Response.new @client.body_str, @client.response_code
end

.post(url, data) ⇒ Object



31
32
33
34
35
36
# File 'lib/tire/http/clients/curb.rb', line 31

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



38
39
40
41
42
# File 'lib/tire/http/clients/curb.rb', line 38

def self.put(url, data)
  @client.url = url
  @client.http_put data
  Response.new @client.body_str, @client.response_code
end