From 456fb9f60a7bbdc73150798bee29216c1559666b Mon Sep 17 00:00:00 2001 From: Matthew Keeler Date: Wed, 25 Mar 2026 12:23:17 -0400 Subject: [PATCH 1/2] chore: Support http.rb v6 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 --- contract-tests/Gemfile | 2 +- launchdarkly-server-sdk.gemspec | 4 ++-- lib/ldclient-rb/impl/data_source/requestor.rb | 4 +--- lib/ldclient-rb/impl/event_sender.rb | 5 +---- lib/ldclient-rb/impl/util.rb | 10 +++++----- 5 files changed, 10 insertions(+), 15 deletions(-) diff --git a/contract-tests/Gemfile b/contract-tests/Gemfile index 5bf3d7c4..e70f6008 100644 --- a/contract-tests/Gemfile +++ b/contract-tests/Gemfile @@ -2,7 +2,7 @@ source 'https://rubygems.org' gem 'launchdarkly-server-sdk', path: '..' -gem 'http', '~> 5.1' +gem 'http', '>= 5.1', '< 7.0' gem 'json' gem "puma", "~> 6.6" gem "rackup", "~> 2.2" diff --git a/launchdarkly-server-sdk.gemspec b/launchdarkly-server-sdk.gemspec index 0bed3f26..25ba2f96 100644 --- a/launchdarkly-server-sdk.gemspec +++ b/launchdarkly-server-sdk.gemspec @@ -42,7 +42,7 @@ Gem::Specification.new do |spec| spec.add_runtime_dependency "benchmark", "~> 0.1", ">= 0.1.1" spec.add_runtime_dependency "concurrent-ruby", "~> 1.1" - spec.add_runtime_dependency "ld-eventsource", "2.5.1" + spec.add_runtime_dependency "ld-eventsource", "2.6.0" spec.add_runtime_dependency "observer", "~> 0.1.2" spec.add_runtime_dependency "openssl", ">= 3.1.2", "< 5.0" spec.add_runtime_dependency "semantic", "~> 1.6" @@ -50,6 +50,6 @@ Gem::Specification.new do |spec| # Please keep ld-eventsource dependency as an exact version so that bugfixes to # that LD library are always associated with a new SDK version. - spec.add_runtime_dependency "http", ">= 4.4.0", "< 6.0.0" + spec.add_runtime_dependency "http", ">= 4.4.0", "< 7.0.0" spec.add_runtime_dependency "json", "~> 2.3" end diff --git a/lib/ldclient-rb/impl/data_source/requestor.rb b/lib/ldclient-rb/impl/data_source/requestor.rb index 9bf81417..f1e714f5 100644 --- a/lib/ldclient-rb/impl/data_source/requestor.rb +++ b/lib/ldclient-rb/impl/data_source/requestor.rb @@ -64,9 +64,7 @@ def make_request(path) unless cached.nil? headers["If-None-Match"] = cached.etag end - response = @http_client.request("GET", uri, { - headers: headers, - }) + response = @http_client.request("GET", uri, headers: headers) status = response.status.code # must fully read body for persistent connections body = response.to_s diff --git a/lib/ldclient-rb/impl/event_sender.rb b/lib/ldclient-rb/impl/event_sender.rb index 660c7df7..f98703d4 100644 --- a/lib/ldclient-rb/impl/event_sender.rb +++ b/lib/ldclient-rb/impl/event_sender.rb @@ -67,10 +67,7 @@ def send_event_data(event_data, description, is_diagnostic) body = gzip.close.string end - response = http_client.request("POST", uri, { - headers: headers, - body: body, - }) + response = http_client.request("POST", uri, headers: headers, body: body) rescue StandardError => exn @logger.warn { "[LDClient] Error sending events: #{exn.inspect}." } next diff --git a/lib/ldclient-rb/impl/util.rb b/lib/ldclient-rb/impl/util.rb index 48dc33a1..3ade4f2a 100644 --- a/lib/ldclient-rb/impl/util.rb +++ b/lib/ldclient-rb/impl/util.rb @@ -127,22 +127,22 @@ def self.add_payload_filter_key(uri, config) def self.new_http_client(http_config) http_client_options = {} if http_config.socket_factory - http_client_options["socket_class"] = http_config.socket_factory + http_client_options[:socket_class] = http_config.socket_factory end proxy = URI.parse(http_config.base_uri).find_proxy unless proxy.nil? - http_client_options["proxy"] = { + http_client_options[:proxy] = { proxy_address: proxy.host, proxy_port: proxy.port, proxy_username: proxy.user, proxy_password: proxy.password, } end - HTTP::Client.new(http_client_options) - .timeout({ + HTTP::Client.new(**http_client_options) + .timeout( read: http_config.read_timeout, connect: http_config.connect_timeout, - }) + ) .persistent(http_config.base_uri) end From a8ab91cc730d9c135cc519d5b2646d9f1be22f4a Mon Sep 17 00:00:00 2001 From: Matthew Keeler Date: Thu, 26 Mar 2026 13:25:38 -0400 Subject: [PATCH 2/2] rubocop fix --- lib/ldclient-rb/impl/util.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/ldclient-rb/impl/util.rb b/lib/ldclient-rb/impl/util.rb index 3ade4f2a..6748295a 100644 --- a/lib/ldclient-rb/impl/util.rb +++ b/lib/ldclient-rb/impl/util.rb @@ -141,7 +141,7 @@ def self.new_http_client(http_config) HTTP::Client.new(**http_client_options) .timeout( read: http_config.read_timeout, - connect: http_config.connect_timeout, + connect: http_config.connect_timeout ) .persistent(http_config.base_uri) end