mirror of
https://gh.wpcy.net/https://github.com/discourse/discourse.git
synced 2026-05-26 21:18:34 +08:00
* Style/RedundantFreeze * Style/RedundantConditional * Lint/DuplicateMagicComment * Lint/IdentityComparison * Lint/SymbolConversion (to be enabled in the shared config)
15 lines
415 B
Ruby
Vendored
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)
|