@@ -75,7 +75,7 @@ def initialize(arguments = {}, &block)
75
75
end
76
76
77
77
# Should just be run once at startup
78
- def build_client ( options = { } )
78
+ def build_client ( options = { } )
79
79
client_options = options [ :transport_options ] || { }
80
80
client_options [ :ssl ] = options [ :ssl ] || { }
81
81
@@ -94,22 +94,22 @@ def perform_request(method, path, params={}, body=nil, headers=nil, opts={})
94
94
95
95
params [ :body ] = body if body
96
96
params [ :headers ] = headers if headers
97
- params = params . merge @request_options
97
+ params = params . merge ( @request_options )
98
98
case method
99
- when " GET"
99
+ when ' GET'
100
100
resp = connection . connection . get ( url , params )
101
- when " HEAD"
101
+ when ' HEAD'
102
102
resp = connection . connection . head ( url , params )
103
- when " PUT"
103
+ when ' PUT'
104
104
resp = connection . connection . put ( url , params )
105
- when " POST"
105
+ when ' POST'
106
106
resp = connection . connection . post ( url , params )
107
- when " DELETE"
107
+ when ' DELETE'
108
108
resp = connection . connection . delete ( url , params )
109
109
else
110
110
raise ArgumentError . new "Method #{ method } not supported"
111
111
end
112
- Response . new resp . code , resp . read_body , resp . headers
112
+ Response . new ( resp . code , resp . read_body , resp . headers )
113
113
end
114
114
end
115
115
@@ -121,20 +121,19 @@ def perform_request(method, path, params={}, body=nil, headers=nil, opts={})
121
121
def __build_connections
122
122
apply_headers ( options )
123
123
124
- Connections ::Collection . new \
125
- : connections => hosts . map { |host |
126
- host [ :protocol ] = host [ :scheme ] || DEFAULT_PROTOCOL
127
- host [ :port ] ||= DEFAULT_PORT
124
+ Connections ::Collection . new (
125
+ connections : hosts . map do |host |
126
+ host [ :protocol ] = host [ :scheme ] || DEFAULT_PROTOCOL
127
+ host [ :port ] ||= DEFAULT_PORT
128
128
129
129
host . delete ( :user ) # auth is not supported here.
130
130
host . delete ( :password ) # use the headers
131
131
132
- Connections ::Connection . new \
133
- :host => host ,
134
- :connection => @manticore
135
- } ,
136
- :selector_class => options [ :selector_class ] ,
137
- :selector => options [ :selector ]
132
+ Connections ::Connection . new ( host : host , connection : @manticore )
133
+ end ,
134
+ selector_class : options [ :selector_class ] ,
135
+ selector : options [ :selector ]
136
+ )
138
137
end
139
138
140
139
# Closes all connections by marking them as dead
@@ -163,15 +162,15 @@ def host_unreachable_exceptions
163
162
private
164
163
165
164
def apply_headers ( options )
166
- headers = options . dig ( :headers ) || options . dig ( :transport_options , :headers ) || { }
165
+ headers = options [ :headers ] || options . dig ( :transport_options , :headers ) || { }
167
166
headers [ CONTENT_TYPE_STR ] = find_value ( headers , CONTENT_TYPE_REGEX ) || DEFAULT_CONTENT_TYPE
168
167
headers [ USER_AGENT_STR ] = find_value ( headers , USER_AGENT_REGEX ) || find_value ( @request_options [ :headers ] , USER_AGENT_REGEX ) || user_agent_header
169
168
headers [ ACCEPT_ENCODING ] = GZIP if use_compression?
170
169
@request_options [ :headers ] . merge! ( headers )
171
170
end
172
171
173
172
def user_agent_header
174
- @user_agent ||= begin
173
+ @user_agent_header ||= begin
175
174
meta = [ "RUBY_VERSION: #{ JRUBY_VERSION } " ]
176
175
if RbConfig ::CONFIG && RbConfig ::CONFIG [ 'host_os' ]
177
176
meta << "#{ RbConfig ::CONFIG [ 'host_os' ] . split ( '_' ) . first [ /[a-z]+/i ] . downcase } #{ RbConfig ::CONFIG [ 'target_cpu' ] } "
0 commit comments