Sha256: ad22777cd9bada51a241f097fdadda37edc55866f6ce4a0ee643eee13df209b5
Contents?: true
Size: 1.23 KB
Versions: 3
Compression:
Stored size: 1.23 KB
Contents
# frozen_string_literal: true module ElasticAPM module Transport # @api private class Headers HEADERS = { 'Content-Type' => 'application/x-ndjson', 'Transfer-Encoding' => 'chunked' }.freeze GZIP_HEADERS = HEADERS.merge( 'Content-Encoding' => 'gzip' ).freeze def initialize(config, initial: {}) @config = config @hash = build!(initial) end attr_accessor :hash def [](key) @hash[key] end def []=(key, value) @hash[key] = value end def merge(other) self.class.new(@config, initial: @hash.merge(other)) end def merge!(other) @hash.merge!(other) self end def to_h @hash end def chunked merge( @config.http_compression? ? GZIP_HEADERS : HEADERS ) end private def build!(headers) headers[:'User-Agent'] = UserAgent.new(@config).to_s if (token = @config.secret_token) headers[:Authorization] = "Bearer #{token}" end if (api_key = @config.api_key) headers[:Authorization] = "ApiKey #{api_key}" end headers end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
elastic-apm-3.6.0 | lib/elastic_apm/transport/headers.rb |
elastic-apm-3.5.0 | lib/elastic_apm/transport/headers.rb |
elastic-apm-3.4.0 | lib/elastic_apm/transport/headers.rb |