Class: HTTPI::Adapter::HTTPClient

Inherits:
Object
  • Object
show all
Defined in:
lib/httpi/adapter/httpclient.rb

Overview

HTTPI::Adapter::HTTPClient

Adapter for the HTTPClient client. rubygems.org/gems/httpclient

Instance Method Summary collapse

Constructor Details

#initialize(request = nil) ⇒ HTTPClient

Returns a new instance of HTTPClient.



12
13
# File 'lib/httpi/adapter/httpclient.rb', line 12

def initialize(request = nil)
end

Instance Method Details

#clientObject

Returns a memoized HTTPClient instance.



16
17
18
# File 'lib/httpi/adapter/httpclient.rb', line 16

def client
  @client ||= ::HTTPClient.new
end

#delete(request) ⇒ Object

Executes an HTTP DELETE request.

See Also:



54
55
56
57
58
# File 'lib/httpi/adapter/httpclient.rb', line 54

def delete(request)
  do_request request do |url, headers|
    client.delete url, headers
  end
end

#get(request) ⇒ Object

Executes an HTTP GET request.

See Also:



22
23
24
25
26
# File 'lib/httpi/adapter/httpclient.rb', line 22

def get(request)
  do_request request do |url, headers|
    client.get url, nil, headers
  end
end

#head(request) ⇒ Object

Executes an HTTP HEAD request.

See Also:



38
39
40
41
42
# File 'lib/httpi/adapter/httpclient.rb', line 38

def head(request)
  do_request request do |url, headers|
    client.head url, nil, headers
  end
end

#post(request) ⇒ Object

Executes an HTTP POST request.

See Also:



30
31
32
33
34
# File 'lib/httpi/adapter/httpclient.rb', line 30

def post(request)
  do_request request do |url, headers, body|
    client.post url, body, headers
  end
end

#put(request) ⇒ Object

Executes an HTTP PUT request.

See Also:



46
47
48
49
50
# File 'lib/httpi/adapter/httpclient.rb', line 46

def put(request)
  do_request request do |url, headers, body|
    client.put url, body, headers
  end
end