Skip to content

Commit 2e2b66f

Browse files
authored
feat: Expand version support for http.rb v6 (#375)
Widen http gem constraint from < 6.0.0 to < 7.0.0 and update HTTP client usage for v6 compatibility: use symbol keys and double-splat for HTTP::Client.new, pass keyword args to .timeout() and .request(). fixes #373
1 parent e7a00bb commit 2e2b66f

5 files changed

Lines changed: 11 additions & 16 deletions

File tree

contract-tests/Gemfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ source 'https://rubygems.org'
22

33
gem 'launchdarkly-server-sdk', path: '..'
44

5-
gem 'http', '~> 5.1'
5+
gem 'http', '>= 5.1', '< 7.0'
66
gem 'json'
77
gem "puma", "~> 6.6"
88
gem "rackup", "~> 2.2"

launchdarkly-server-sdk.gemspec

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,14 +42,14 @@ Gem::Specification.new do |spec|
4242

4343
spec.add_runtime_dependency "benchmark", "~> 0.1", ">= 0.1.1"
4444
spec.add_runtime_dependency "concurrent-ruby", "~> 1.1"
45-
spec.add_runtime_dependency "ld-eventsource", "2.5.1"
45+
spec.add_runtime_dependency "ld-eventsource", "2.6.0"
4646
spec.add_runtime_dependency "observer", "~> 0.1.2"
4747
spec.add_runtime_dependency "openssl", ">= 3.1.2", "< 5.0"
4848
spec.add_runtime_dependency "semantic", "~> 1.6"
4949
spec.add_runtime_dependency "zlib", "~> 3.1" unless RUBY_PLATFORM == "java"
5050
# Please keep ld-eventsource dependency as an exact version so that bugfixes to
5151
# that LD library are always associated with a new SDK version.
5252

53-
spec.add_runtime_dependency "http", ">= 4.4.0", "< 6.0.0"
53+
spec.add_runtime_dependency "http", ">= 4.4.0", "< 7.0.0"
5454
spec.add_runtime_dependency "json", "~> 2.3"
5555
end

lib/ldclient-rb/impl/data_source/requestor.rb

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,9 +64,7 @@ def make_request(path)
6464
unless cached.nil?
6565
headers["If-None-Match"] = cached.etag
6666
end
67-
response = @http_client.request("GET", uri, {
68-
headers: headers,
69-
})
67+
response = @http_client.request("GET", uri, headers: headers)
7068
status = response.status.code
7169
# must fully read body for persistent connections
7270
body = response.to_s

lib/ldclient-rb/impl/event_sender.rb

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -67,10 +67,7 @@ def send_event_data(event_data, description, is_diagnostic)
6767
body = gzip.close.string
6868
end
6969

70-
response = http_client.request("POST", uri, {
71-
headers: headers,
72-
body: body,
73-
})
70+
response = http_client.request("POST", uri, headers: headers, body: body)
7471
rescue StandardError => exn
7572
@logger.warn { "[LDClient] Error sending events: #{exn.inspect}." }
7673
next

lib/ldclient-rb/impl/util.rb

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -127,22 +127,22 @@ def self.add_payload_filter_key(uri, config)
127127
def self.new_http_client(http_config)
128128
http_client_options = {}
129129
if http_config.socket_factory
130-
http_client_options["socket_class"] = http_config.socket_factory
130+
http_client_options[:socket_class] = http_config.socket_factory
131131
end
132132
proxy = URI.parse(http_config.base_uri).find_proxy
133133
unless proxy.nil?
134-
http_client_options["proxy"] = {
134+
http_client_options[:proxy] = {
135135
proxy_address: proxy.host,
136136
proxy_port: proxy.port,
137137
proxy_username: proxy.user,
138138
proxy_password: proxy.password,
139139
}
140140
end
141-
HTTP::Client.new(http_client_options)
142-
.timeout({
141+
HTTP::Client.new(**http_client_options)
142+
.timeout(
143143
read: http_config.read_timeout,
144-
connect: http_config.connect_timeout,
145-
})
144+
connect: http_config.connect_timeout
145+
)
146146
.persistent(http_config.base_uri)
147147
end
148148

0 commit comments

Comments
 (0)