def application_path( request, is_secure = false, port = nil )
protocol = nil
if is_secure == true then
protocol = 'https://'
else
protocol = 'http://'
end
domain = request.server_name || 'localhost'
if port.nil? and request.server_port then
port = request.server_port.to_i
end
if port == 80 then
port = nil
end
script = (request.script_name || @application.path).dup
script.sub!(/\A\//, '')
if port then
path = "#{protocol}#{domain}:#{port}/#{script}"
path.gsub!(/\/\Z/, '')
else
path = "#{protocol}#{domain}/#{script}"
end
path
end