From b1501fac7a9b2ce1a75d4b6f1a1632bc1da3df0d Mon Sep 17 00:00:00 2001 From: Eugene Lapeko Date: Tue, 22 Aug 2023 23:28:48 +0300 Subject: [PATCH 1/3] Sending accept_encoding breaks response processing in some cases. --- lib/rating_chgk_v2/connection.rb | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/lib/rating_chgk_v2/connection.rb b/lib/rating_chgk_v2/connection.rb index 5f734be..0b6f83f 100644 --- a/lib/rating_chgk_v2/connection.rb +++ b/lib/rating_chgk_v2/connection.rb @@ -16,8 +16,7 @@ def options(client) headers = { accept: 'application/json', user_agent: "rating-chgk-v2 gem/#{RatingChgkV2::VERSION}", - 'Content-Type': 'application/json', - accept_encoding: 'gzip,deflate,br' + 'Content-Type': 'application/json' } headers = headers.merge({Authorization: "Bearer #{client.token}"}) if client.token From 2127ce86944b012245348b96e14f5e81e5039a50 Mon Sep 17 00:00:00 2001 From: Eugene Lapeko Date: Tue, 22 Aug 2023 23:32:35 +0300 Subject: [PATCH 2/3] Do not send Authorization header with empty token --- lib/rating_chgk_v2/connection.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/rating_chgk_v2/connection.rb b/lib/rating_chgk_v2/connection.rb index 0b6f83f..a91a382 100644 --- a/lib/rating_chgk_v2/connection.rb +++ b/lib/rating_chgk_v2/connection.rb @@ -19,7 +19,7 @@ def options(client) 'Content-Type': 'application/json' } - headers = headers.merge({Authorization: "Bearer #{client.token}"}) if client.token + headers = headers.merge({Authorization: "Bearer #{client.token}"}) unless client.token.empty? {headers: headers, url: BASE_URL} end From d0a749c81589118e0e4307e340e84f8beda7fca1 Mon Sep 17 00:00:00 2001 From: Eugene Lapeko Date: Tue, 22 Aug 2023 23:44:17 +0300 Subject: [PATCH 3/3] Also expect nil as token --- lib/rating_chgk_v2/connection.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/rating_chgk_v2/connection.rb b/lib/rating_chgk_v2/connection.rb index a91a382..ec95340 100644 --- a/lib/rating_chgk_v2/connection.rb +++ b/lib/rating_chgk_v2/connection.rb @@ -19,7 +19,7 @@ def options(client) 'Content-Type': 'application/json' } - headers = headers.merge({Authorization: "Bearer #{client.token}"}) unless client.token.empty? + headers = headers.merge({Authorization: "Bearer #{client.token}"}) unless client.token.to_s.empty? {headers: headers, url: BASE_URL} end