lib/wmap/utils/url_magic.rb
# Test the URL / site and return the redirection location (3xx response code only)
Test the URL / site and return the redirection location (3xx response code only)
Test the URL / site and return the redirection location ( 3xx response code only )
def redirect_location (url)
		puts "Test the redirection location for the url: #{url}" if @verbose
		location=""
		raise "Invalid url: #{url}" unless is_url?(url)
		url=url.strip.downcase
		timeo = Max_http_timeout/1000.0
		uri = URI.parse(url)
		code = response_code (url)
		if code >= 300 && code < 400
			http = Net::HTTP.new(uri.host, uri.port)
			http.open_timeout = timeo
			http.read_timeout = timeo
			if (url =~ /https\:/i)
				http.use_ssl = true
				http.verify_mode = OpenSSL::SSL::VERIFY_NONE
				http.ssl_version = @ssl_version
			end
			request = Net::HTTP::Get.new(uri.request_uri)
			response = http.request(request)
			puts "Response: #{response}" if @verbose
			case response
			when Net::HTTPRedirection then
				location = response['location']
			end
		end
		return location
	rescue Exception => ee
		puts "Exception on method redirect_location for URL #{url}: #{ee}" if @verbose
		return ""
	end
def redirect_location ( url ) puts "Test the redirection location for the url: #{url}" if @verbose location = "" raise "Invalid url: #{url}" unless is_url? ( url ) url = url . strip . downcase timeo = Max_http_timeout / 1000.0 uri = URI . parse ( url ) code = response_code ( url ) if code >= 300 && code < 400 http = Net :: HTTP . new ( uri . host , uri . port ) http . open_timeout = timeo http . read_timeout = timeo if ( url =~ / https \: /i ) http . use_ssl = true http . verify_mode = OpenSSL :: SSL :: VERIFY_NONE http . ssl_version = @ssl_version end request = Net :: HTTP :: Get . new ( uri . request_uri ) response = http . request ( request ) puts "Response: #{response}" if @verbose case response when Net :: HTTPRedirection then location = response [ 'location' ] end end return location rescue Exception => ee puts "Exception on method redirect_location for URL #{url}: #{ee}" if @verbose return "" end
Test the URL / site and return the redirection location (3xx response code only)
Test the URL / site and return the redirection location ( 3xx response code only )
# Bypass the remote web server cert validation test
url
<not_specific>