Class: Puppet::Network::HTTP::ConnectionAdapter
Constant Summary
Constants inherited
from Connection
Puppet::Network::HTTP::Connection::OPTION_DEFAULTS
Instance Method Summary
collapse
-
#delete(path, headers = {'Depth' => 'Infinity'}, options = {}) ⇒ Object
-
#get(path, headers = {}, options = {}) ⇒ Object
-
#head(path, headers = {}, options = {}) ⇒ Object
-
#initialize(host, port, options = {}) ⇒ ConnectionAdapter
constructor
A new instance of ConnectionAdapter.
-
#post(path, data, headers = nil, options = {}) ⇒ Object
-
#put(path, data, headers = nil, options = {}) ⇒ Object
-
#request_get(*args, &block) ⇒ Object
-
#request_head(*args) {|response.nethttp| ... } ⇒ Object
-
#request_post(*args, &block) ⇒ Object
Methods inherited from Connection
#address, #port, #request, #use_ssl?, #verifier
Constructor Details
#initialize(host, port, options = {}) ⇒ ConnectionAdapter
Returns a new instance of ConnectionAdapter.
2
3
4
5
6
|
# File 'lib/puppet/network/http/connection_adapter.rb', line 2
def initialize(host, port, options = {})
super(host, port, options)
@client = Puppet.runtime[:http]
end
|
Instance Method Details
#delete(path, headers = {'Depth' => 'Infinity'}, options = {}) ⇒ Object
43
44
45
46
47
48
49
50
51
52
|
# File 'lib/puppet/network/http/connection_adapter.rb', line 43
def delete(path, = {'Depth' => 'Infinity'}, options = {})
||= {}
options[:ssl_context] ||= resolve_ssl_context
options[:redirect_limit] ||= @redirect_limit
with_error_handling do
resp = @client.delete(to_url(path), headers: , options: options)
resp.nethttp
end
end
|
#get(path, headers = {}, options = {}) ⇒ Object
8
9
10
11
12
13
14
15
16
17
|
# File 'lib/puppet/network/http/connection_adapter.rb', line 8
def get(path, = {}, options = {})
||= {}
options[:ssl_context] ||= resolve_ssl_context
options[:redirect_limit] ||= @redirect_limit
with_error_handling do
resp = @client.get(to_url(path), headers: , options: options)
resp.nethttp
end
end
|
#head(path, headers = {}, options = {}) ⇒ Object
32
33
34
35
36
37
38
39
40
41
|
# File 'lib/puppet/network/http/connection_adapter.rb', line 32
def head(path, = {}, options = {})
||= {}
options[:ssl_context] ||= resolve_ssl_context
options[:redirect_limit] ||= @redirect_limit
with_error_handling do
resp = @client.head(to_url(path), headers: , options: options)
resp.nethttp
end
end
|
#post(path, data, headers = nil, options = {}) ⇒ Object
19
20
21
22
23
24
25
26
27
28
29
30
|
# File 'lib/puppet/network/http/connection_adapter.rb', line 19
def post(path, data, = nil, options = {})
||= {}
['Content-Type'] ||= "application/x-www-form-urlencoded"
data ||= ''
options[:ssl_context] ||= resolve_ssl_context
options[:redirect_limit] ||= @redirect_limit
with_error_handling do
resp = @client.post(to_url(path), data, headers: , options: options)
resp.nethttp
end
end
|
#put(path, data, headers = nil, options = {}) ⇒ Object
54
55
56
57
58
59
60
61
62
63
64
65
|
# File 'lib/puppet/network/http/connection_adapter.rb', line 54
def put(path, data, = nil, options = {})
||= {}
['Content-Type'] ||= "application/x-www-form-urlencoded"
data ||= ''
options[:ssl_context] ||= resolve_ssl_context
options[:redirect_limit] ||= @redirect_limit
with_error_handling do
resp = @client.put(to_url(path), data, headers: , options: options)
resp.nethttp
end
end
|
#request_get(*args, &block) ⇒ Object
67
68
69
70
71
72
73
74
75
76
77
78
79
|
# File 'lib/puppet/network/http/connection_adapter.rb', line 67
def request_get(*args, &block)
path, = *args
||= {}
options = {
ssl_context: resolve_ssl_context,
redirect_limit: @redirect_limit
}
resp = @client.get(to_url(path), headers: , options: options) do |response|
yield response.nethttp if block_given?
end
resp.nethttp
end
|
#request_head(*args) {|response.nethttp| ... } ⇒ Object
81
82
83
84
85
86
87
88
89
90
91
92
|
# File 'lib/puppet/network/http/connection_adapter.rb', line 81
def request_head(*args, &block)
path, = *args
||= {}
options = {
ssl_context: resolve_ssl_context,
redirect_limit: @redirect_limit
}
response = @client.head(to_url(path), headers: , options: options)
yield response.nethttp if block_given?
response.nethttp
end
|
#request_post(*args, &block) ⇒ Object
94
95
96
97
98
99
100
101
102
103
104
105
106
107
|
# File 'lib/puppet/network/http/connection_adapter.rb', line 94
def request_post(*args, &block)
path, data, = *args
||= {}
['Content-Type'] ||= "application/x-www-form-urlencoded"
options = {
ssl_context: resolve_ssl_context,
redirect_limit: @redirect_limit
}
resp = @client.post(to_url(path), data, headers: , options: options) do |response|
yield response.nethttp if block_given?
end
resp.nethttp
end
|