From 2652c19933189f66693e845c88c9d6d4bf4ec728 Mon Sep 17 00:00:00 2001 From: Laurent Martin Date: Mon, 20 Mar 2023 18:27:20 +0100 Subject: [PATCH] better detection if there is redirect --- lib/aspera/cli/plugins/config.rb | 3 ++- lib/aspera/cli/plugins/faspex.rb | 2 +- lib/aspera/cli/plugins/faspex5.rb | 5 +++-- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/lib/aspera/cli/plugins/config.rb b/lib/aspera/cli/plugins/config.rb index 907fcc2f..8fab4ca5 100644 --- a/lib/aspera/cli/plugins/config.rb +++ b/lib/aspera/cli/plugins/config.rb @@ -582,7 +582,8 @@ def identify_plugin_for_url(url) Log.log.debug{"Cannot detect #{plugin_name_sym} : #{e.message}"} end end - return detection_info.merge(product: plugin_name_sym, url: current_url) unless detection_info.nil? + # if there is a redirect, then the detector can override the url. + return {product: plugin_name_sym, url: current_url}.merge(detection_info) unless detection_info.nil? end # loop raise "No known application found at #{url}" end diff --git a/lib/aspera/cli/plugins/faspex.rb b/lib/aspera/cli/plugins/faspex.rb index e4424269..1a50b28a 100644 --- a/lib/aspera/cli/plugins/faspex.rb +++ b/lib/aspera/cli/plugins/faspex.rb @@ -46,7 +46,7 @@ def detect(base_url) if result[:http].body.start_with?(' false}) version = res_s['XRD']['application']['version'] - return {version: version} + return {version: version, url: result[:http].uri} end return nil end diff --git a/lib/aspera/cli/plugins/faspex5.rb b/lib/aspera/cli/plugins/faspex5.rb index 4d9edf64..a37e998d 100644 --- a/lib/aspera/cli/plugins/faspex5.rb +++ b/lib/aspera/cli/plugins/faspex5.rb @@ -17,12 +17,13 @@ module Plugins class Faspex5 < Aspera::Cli::BasicAuthPlugin RECIPIENT_TYPES = %w[user workgroup external_user distribution_list shared_inbox].freeze PACKAGE_TERMINATED = %w[completed failed].freeze + API_DETECT = 'api/v5/configuration/ping' class << self def detect(base_url) api = Rest.new(base_url: base_url, redirect_max: 1) - result = api.read('api/v5/configuration/ping') + result = api.read(API_DETECT) if result[:http].code.start_with?('2') && result[:http].body.strip.empty? - return {version: '5'} + return {version: '5', url: result[:http].uri.to_s[0..-(API_DETECT.length + 2)]} end return nil end