Class: Crabfarm::HttpClient
- Inherits:
-
Object
- Object
- Crabfarm::HttpClient
show all
- Defined in:
- lib/crabfarm/http_client.rb
Defined Under Namespace
Classes: HttpRequestError, MaximumRedirectsError
Instance Attribute Summary collapse
Instance Method Summary
collapse
Constructor Details
#initialize(_proxy = nil) ⇒ HttpClient
27
28
29
30
31
32
33
34
|
# File 'lib/crabfarm/http_client.rb', line 27
def initialize(_proxy=nil)
if _proxy.nil?
@proxy_addr = nil
@proxy_port = nil
else
@proxy_addr, @proxy_port = _proxy.split ':'
end
end
|
Instance Attribute Details
#proxy_addr ⇒ Object
Returns the value of attribute proxy_addr.
25
26
27
|
# File 'lib/crabfarm/http_client.rb', line 25
def proxy_addr
@proxy_addr
end
|
#proxy_port ⇒ Object
Returns the value of attribute proxy_port.
25
26
27
|
# File 'lib/crabfarm/http_client.rb', line 25
def proxy_port
@proxy_port
end
|
Instance Method Details
#delete(_url) ⇒ Object
53
54
55
|
# File 'lib/crabfarm/http_client.rb', line 53
def delete(_url)
perform_request Net::HTTP::Delete, URI(_url),
end
|
#get(_url, _query = {}, _headers = {}) ⇒ Object
36
37
38
39
|
# File 'lib/crabfarm/http_client.rb', line 36
def get(_url, _query={}, ={})
uri = URI _url
perform_request Net::HTTP::Get, uri,
end
|
#post(_url, _data, _headers = {}) ⇒ Object
41
42
43
44
45
|
# File 'lib/crabfarm/http_client.rb', line 41
def post(_url, _data, ={})
perform_request Net::HTTP::Post, URI(_url), do |req|
req.body = prepare_data(_data)
end
end
|
#put(_url, _data, _headers = {}) ⇒ Object
47
48
49
50
51
|
# File 'lib/crabfarm/http_client.rb', line 47
def put(_url, _data, ={})
perform_request Net::HTTP::Put, URI(_url), do |req|
req.body = prepare_data(_data)
end
end
|