From 6fa1a57fdacb2f983c2b88b75420ba57e2f7bb08 Mon Sep 17 00:00:00 2001 From: Ward Wouts Date: Tue, 30 Sep 2008 13:52:40 +0000 Subject: [PATCH] fix voor ssl --- listversioned/listversioned.rb | 48 +++++++++++++++++++++------------- 1 file changed, 30 insertions(+), 18 deletions(-) diff --git a/listversioned/listversioned.rb b/listversioned/listversioned.rb index ea8aabc..2c3f4fb 100755 --- a/listversioned/listversioned.rb +++ b/listversioned/listversioned.rb @@ -31,6 +31,7 @@ Usage: #{$0.sub(/.*\//, "")} [options] -u -h, --help show this message -u set baseurl +-s use ssl EOT exit end @@ -40,7 +41,8 @@ def cmdline begin opts = GetoptLong.new( [ "-h", "--help", GetoptLong::NO_ARGUMENT ], - [ "-u", GetoptLong::REQUIRED_ARGUMENT ] + [ "-u", GetoptLong::REQUIRED_ARGUMENT ], + [ "-s", GetoptLong::NO_ARGUMENT ] ) opts.quiet=true @@ -67,23 +69,24 @@ def fetch(uri_str, limit = 10) path = URI.parse(uri_str).path query = URI.parse(uri_str).query - Net::HTTP.start(host, port) {|http| - if query - req = Net::HTTP::Get.new("#{URI.escape(path)}?#{URI.escape(query)}") - else - req = Net::HTTP::Get.new("#{URI.escape(path)}") - end - req.basic_auth @user, @pass - response = http.request(req) - case response - when Net::HTTPSuccess then response - when Net::HTTPRedirection then fetch(response['location'], limit - 1) - when Net::HTTPNotFound then puts "404 Not Found #{uri_str}"; response.error! - when Net::HTTPUnauthorized then puts "401 Authorization Required #{uri_str}"; response.error! - else - response.error! - end - } + http = Net::HTTP.new(host, port) + http.use_ssl = @use_ssl + if query + req = Net::HTTP::Get.new("#{URI.escape(path)}?#{URI.escape(query)}") + else + req = Net::HTTP::Get.new("#{URI.escape(path)}") + end + req.basic_auth @user, @pass + response = http.request(req) + case response + when Net::HTTPSuccess then response + when Net::HTTPRedirection then fetch(response['location'], limit - 1) + when Net::HTTPNotFound then puts "404 Not Found #{uri_str}"; response.error! + when Net::HTTPUnauthorized then puts "401 Authorization Required #{uri_str}"; response.error! + when Net::HTTPUnauthorized then puts "401 Authorization Required #{uri_str}"; response.error! + else + response.error! + end end def svnparse(url) @@ -153,6 +156,7 @@ def cvsparse(url) begin body = fetch("#{url}/CVS/Entries").body rescue + p $! end dirs = Array.new body.each{|line| @@ -174,6 +178,12 @@ if options["-u"].nil? usage end +if options["-s"] + @use_ssl = true +else + @use_ssl = false +end + mode=nil # first test for subversion entries @@ -182,6 +192,7 @@ if mode.nil? body = fetch("#{options["-u"]}/.svn/entries").body mode="subversion" rescue + p $! end end @@ -191,6 +202,7 @@ if mode.nil? body = fetch("#{options["-u"]}/CVS/Entries").body mode="cvs" rescue + p $! end end