Skip to content

Commit

Permalink
better detection if there is redirect
Browse files Browse the repository at this point in the history
  • Loading branch information
laurent-martin committed Mar 20, 2023
1 parent a3ad877 commit 2652c19
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
3 changes: 2 additions & 1 deletion lib/aspera/cli/plugins/config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion lib/aspera/cli/plugins/faspex.rb
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ def detect(base_url)
if result[:http].body.start_with?('<?xml')
res_s = XmlSimple.xml_in(result[:http].body, {'ForceArray' => false})
version = res_s['XRD']['application']['version']
return {version: version}
return {version: version, url: result[:http].uri}
end
return nil
end
Expand Down
5 changes: 3 additions & 2 deletions lib/aspera/cli/plugins/faspex5.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 2652c19

Please sign in to comment.