From 2ce5c27b4f909c0b8aa7284736c5e5a18858bea6 Mon Sep 17 00:00:00 2001 From: Hans de Graaff Date: Sat, 15 Jul 2023 12:07:55 +0200 Subject: [PATCH 1/2] Use URI.encode_www_form_component URI.escape has been deprecated for a long time and is no longer available in ruby 3.0 and later versions. Fixes #12 --- elasticsearch_ | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/elasticsearch_ b/elasticsearch_ index d4d6f32..94e05f5 100755 --- a/elasticsearch_ +++ b/elasticsearch_ @@ -31,7 +31,7 @@ mode = $0.gsub /.*\/elasticsearch_/, "" if ARGV[0] == "autoconf" begin - node_encode = URI.escape(@node) + node_encode = URI.encode_www_form_component(@node) nodes_d = fetch('/_nodes/'+node_encode); puts "yes" exit 0 @@ -156,7 +156,7 @@ end data = {}; begin - node_encode = URI.escape(@node) + node_encode = URI.encode_www_form_component(@node) stats = fetch('/_nodes/'+node_encode+'/stats'); rescue err.puts "Fetch error" From b95fcf9d0823c9c95d9aa6635e7490eb1d74299d Mon Sep 17 00:00:00 2001 From: Hans de Graaff Date: Sat, 15 Jul 2023 12:09:35 +0200 Subject: [PATCH 2/2] Provide the fetch error to make troubleshooting easier --- elasticsearch_ | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/elasticsearch_ b/elasticsearch_ index 94e05f5..527cd85 100755 --- a/elasticsearch_ +++ b/elasticsearch_ @@ -158,8 +158,8 @@ data = {}; begin node_encode = URI.encode_www_form_component(@node) stats = fetch('/_nodes/'+node_encode+'/stats'); -rescue - err.puts "Fetch error" +rescue => error + err.puts "Fetch error: #{error}" exit 1 end