Skip to content

Commit

Permalink
fix: prevent unleash header overwrite (#234)
Browse files Browse the repository at this point in the history
  • Loading branch information
kwasniew authored Feb 6, 2025
1 parent fb1b7ee commit 85176a9
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
9 changes: 5 additions & 4 deletions lib/unleash/configuration.rb
Original file line number Diff line number Diff line change
Expand Up @@ -51,14 +51,15 @@ def refresh_backup_file!
end

def http_headers
{
headers = {
'User-Agent' => "UnleashClientRuby/#{Unleash::VERSION} #{RUBY_ENGINE}/#{RUBY_VERSION} [#{RUBY_PLATFORM}]",
'UNLEASH-INSTANCEID' => self.instance_id,
'UNLEASH-APPNAME' => self.app_name,
'UNLEASH-CONNECTION-ID' => @connection_id,
'UNLEASH-SDK' => "unleash-client-ruby:#{Unleash::VERSION}",
'Unleash-Client-Spec' => CLIENT_SPECIFICATION_VERSION
'Unleash-Client-Spec' => CLIENT_SPECIFICATION_VERSION,
'UNLEASH-SDK' => "unleash-client-ruby:#{Unleash::VERSION}"
}.merge!(generate_custom_http_headers)
headers['UNLEASH-CONNECTION-ID'] = @connection_id
headers
end

def fetch_toggles_uri
Expand Down
2 changes: 1 addition & 1 deletion spec/unleash/configuration_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@
config = Unleash::Configuration.new(
url: 'https://testurl/api',
app_name: 'test-app',
custom_http_headers: { 'X-API-KEY': '123' }
custom_http_headers: { 'X-API-KEY': '123', 'UNLEASH-CONNECTION-ID': 'ignore' }
)

expect{ config.validate! }.not_to raise_error
Expand Down

0 comments on commit 85176a9

Please sign in to comment.