15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
|
# File 'lib/daddy/http_client.rb', line 15
def get(path, params = {})
Rails.logger.debug "[HttpClient] path: #{path}"
Rails.logger.debug "[HttpClient] params: #{params}"
response = connection.get(path, params) do |request|
if @options[:auth_user] and @options[:auth_password]
basic = 'Basic ' + Base64.encode64(@options[:auth_user] + ':' + @options[:auth_password])
Rails.logger.debug "[HttpClient] authorization: #{basic}"
request.['Authorization'] = basic
end
if @cookie
Rails.logger.debug "[HttpClient] cookie: #{@cookie}"
request.['Cookie'] = @cookie
end
params.each do |key, value|
request.params[key] = value
end
end
@cookie = response.['set-cookie']
if block_given?
yield response
else
Rails.logger.debug "[HttpClient] stutus: #{response.status}"
response.body.force_encoding('UTF-8')
end
end
|