discourse/lib/freedom_patches/net_http_header.rb
Jarek Radosz d89531f2f6
DEV: Enable some minor rubocop rules (#40094)
* Style/RedundantFreeze
* Style/RedundantConditional
* Lint/DuplicateMagicComment
* Lint/IdentityComparison
* Lint/SymbolConversion

(to be enabled in the shared config)
2026-05-19 15:29:38 +02:00

15 lines
415 B
Ruby
Vendored

# frozen_string_literal: true
module NetHTTPHeaderPatch
def initialize_http_header(initheader)
# If no user-agent is set, set it to the default
initheader ||= {}
user_agent_key =
initheader.keys.find { |key| key.to_s.downcase == "user-agent" } || :"User-Agent"
initheader[user_agent_key] ||= Discourse.user_agent
super initheader
end
end
Net::HTTPHeader.prepend(NetHTTPHeaderPatch)