Sha256: 21555cc12b344ca24ee5a3e3894763cfb30b091d3a678f028ab295e41064ff72

Contents?: true

Size: 1.24 KB

Versions: 3

Compression:

Stored size: 1.24 KB

Contents

# encoding: utf-8
require "elasticsearch"
require "elasticsearch/transport/transport/http/manticore"

es_client_version = Gem.loaded_specs['elasticsearch-transport'].version
if es_client_version >= Gem::Version.new('7.2') && es_client_version < Gem::Version.new('7.16')
  # elasticsearch-transport 7.2.0 - 7.14.0 had a bug where setting http headers
  #   ES::Client.new ..., transport_options: { headers: { 'Authorization' => ... } }
  # would be lost https://github.com/elastic/elasticsearch-ruby/issues/1428
  #
  # NOTE: needs to be idempotent as filter ES plugin might apply the same patch!
  #
  # @private
  module Elasticsearch
    module Transport
      module Transport
        module HTTP
          class Manticore

            def apply_headers(request_options, options)
              headers = (options && options[:headers]) || {}
              headers[CONTENT_TYPE_STR] = find_value(headers, CONTENT_TYPE_REGEX) || DEFAULT_CONTENT_TYPE
              headers[USER_AGENT_STR] = find_value(headers, USER_AGENT_REGEX) || user_agent_header
              headers[ACCEPT_ENCODING] = GZIP if use_compression?
              (request_options[:headers] ||= {}).merge!(headers) # this line was changed
            end

          end
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
logstash-input-elasticsearch-4.10.0 lib/logstash/inputs/elasticsearch/patches/_elasticsearch_transport_http_manticore.rb
logstash-input-elasticsearch-4.9.3 lib/logstash/inputs/elasticsearch/patches/_elasticsearch_transport_http_manticore.rb
logstash-input-elasticsearch-4.9.2 lib/logstash/inputs/elasticsearch/patches/_elasticsearch_transport_http_manticore.rb