fix voor ssl

This commit is contained in:
Ward Wouts 2008-09-30 13:52:40 +00:00
parent 6a6d42f402
commit 6fa1a57fda

View file

@ -31,6 +31,7 @@ Usage: #{$0.sub(/.*\//, "")} [options] -u <baseurl>
-h, --help show this message -h, --help show this message
-u <baseurl> set baseurl -u <baseurl> set baseurl
-s use ssl
EOT EOT
exit exit
end end
@ -40,7 +41,8 @@ def cmdline
begin begin
opts = GetoptLong.new( opts = GetoptLong.new(
[ "-h", "--help", GetoptLong::NO_ARGUMENT ], [ "-h", "--help", GetoptLong::NO_ARGUMENT ],
[ "-u", GetoptLong::REQUIRED_ARGUMENT ] [ "-u", GetoptLong::REQUIRED_ARGUMENT ],
[ "-s", GetoptLong::NO_ARGUMENT ]
) )
opts.quiet=true opts.quiet=true
@ -67,23 +69,24 @@ def fetch(uri_str, limit = 10)
path = URI.parse(uri_str).path path = URI.parse(uri_str).path
query = URI.parse(uri_str).query query = URI.parse(uri_str).query
Net::HTTP.start(host, port) {|http| http = Net::HTTP.new(host, port)
if query http.use_ssl = @use_ssl
req = Net::HTTP::Get.new("#{URI.escape(path)}?#{URI.escape(query)}") if query
else req = Net::HTTP::Get.new("#{URI.escape(path)}?#{URI.escape(query)}")
req = Net::HTTP::Get.new("#{URI.escape(path)}") else
end req = Net::HTTP::Get.new("#{URI.escape(path)}")
req.basic_auth @user, @pass end
response = http.request(req) req.basic_auth @user, @pass
case response response = http.request(req)
when Net::HTTPSuccess then response case response
when Net::HTTPRedirection then fetch(response['location'], limit - 1) when Net::HTTPSuccess then response
when Net::HTTPNotFound then puts "404 Not Found #{uri_str}"; response.error! when Net::HTTPRedirection then fetch(response['location'], limit - 1)
when Net::HTTPUnauthorized then puts "401 Authorization Required #{uri_str}"; response.error! when Net::HTTPNotFound then puts "404 Not Found #{uri_str}"; response.error!
else when Net::HTTPUnauthorized then puts "401 Authorization Required #{uri_str}"; response.error!
response.error! when Net::HTTPUnauthorized then puts "401 Authorization Required #{uri_str}"; response.error!
end else
} response.error!
end
end end
def svnparse(url) def svnparse(url)
@ -153,6 +156,7 @@ def cvsparse(url)
begin begin
body = fetch("#{url}/CVS/Entries").body body = fetch("#{url}/CVS/Entries").body
rescue rescue
p $!
end end
dirs = Array.new dirs = Array.new
body.each{|line| body.each{|line|
@ -174,6 +178,12 @@ if options["-u"].nil?
usage usage
end end
if options["-s"]
@use_ssl = true
else
@use_ssl = false
end
mode=nil mode=nil
# first test for subversion entries # first test for subversion entries
@ -182,6 +192,7 @@ if mode.nil?
body = fetch("#{options["-u"]}/.svn/entries").body body = fetch("#{options["-u"]}/.svn/entries").body
mode="subversion" mode="subversion"
rescue rescue
p $!
end end
end end
@ -191,6 +202,7 @@ if mode.nil?
body = fetch("#{options["-u"]}/CVS/Entries").body body = fetch("#{options["-u"]}/CVS/Entries").body
mode="cvs" mode="cvs"
rescue rescue
p $!
end end
end end