lib/wmap/utils/url_magic.rb
# Extract web service port from the url. For example: "https://login.yahoo.com/email/help" -> 443
Extract web service port from the url.
Extract web service port from the url .
def url_2_port (url)
		puts "Retrieve service port on URL: #{url}" if @verbose
		ssl = (url =~ /https/i)
		url = url.downcase.gsub(/(http:\/\/|https:\/\/)/, "")
		record1 = url.split('/')
		record2 = record1[0].split(':')
		if (record2.length == 2)
			puts "The service port: #{record2[1]}" if @verbose
			return record2[1].to_i
		elsif ssl
			puts "The service port: 443" if @verbose
			return 443
		else
			puts "The service port: 80" if @verbose
			return 80
		end
	rescue => ee
		puts "Exception on method #{__method__}: #{ee}" if @verbose
		return nil
	end
def url_2_port ( url ) puts "Retrieve service port on URL: #{url}" if @verbose ssl = ( url =~ / https /i ) url = url . downcase . gsub ( / (http: \/ \/ |https: \/ \/ ) / , "" ) record1 = url . split ( '/' ) record2 = record1 [ 0 ] . split ( ':' ) if ( record2 . length == 2 ) puts "The service port: #{record2[1]}" if @verbose return record2 [ 1 ] . to_i elsif ssl puts "The service port: 443" if @verbose return 443 else puts "The service port: 80" if @verbose return 80 end rescue => ee puts "Exception on method #{__method__}: #{ee}" if @verbose return nil end
Extract web service port from the url.
Extract web service port from the url .
url
<not_specific>