Skip to content

Commit 9e5e91e

Browse files
committed
[CLIENT] Centralize header handling into one method
1 parent c248155 commit 9e5e91e

File tree

3 files changed

+1
-13
lines changed

3 files changed

+1
-13
lines changed

elasticsearch-transport/lib/elasticsearch/transport/transport/base.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -401,6 +401,7 @@ def apply_headers(client, options)
401401
headers = options[:headers] || {}
402402
headers[CONTENT_TYPE_STR] = find_value(headers, CONTENT_TYPE_REGEX) || DEFAULT_CONTENT_TYPE
403403
headers[USER_AGENT_STR] = find_value(headers, USER_AGENT_REGEX) || user_agent_header(client)
404+
client.headers[ACCEPT_ENCODING] = GZIP if use_compression?
404405
client.headers.merge!(headers)
405406
end
406407

elasticsearch-transport/lib/elasticsearch/transport/transport/http/curb.rb

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -104,18 +104,6 @@ def host_unreachable_exceptions
104104

105105
private
106106

107-
def apply_headers(client, options)
108-
super
109-
110-
if use_compression?
111-
if client.headers
112-
client.headers[ACCEPT_ENCODING] = GZIP
113-
else
114-
client.headers = { ACCEPT_ENCODING => GZIP }
115-
end
116-
end
117-
end
118-
119107
def user_agent_header(client)
120108
@user_agent ||= begin
121109
meta = ["RUBY_VERSION: #{RUBY_VERSION}"]

elasticsearch-transport/lib/elasticsearch/transport/transport/http/faraday.rb

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,6 @@ def perform_request(method, path, params={}, body=nil, headers=nil)
5151
# @return [Connections::Connection]
5252
#
5353
def __build_connection(host, options={}, block=nil)
54-
options.merge!(headers: { accept_encoding: GZIP }) if use_compression?
5554
client = ::Faraday.new(__full_url(host), options, &block)
5655
apply_headers(client, options)
5756
Connections::Connection.new :host => host, :connection => client

0 commit comments

Comments
 (0)