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
-u <baseurl> 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,7 +69,8 @@ def fetch(uri_str, limit = 10)
path = URI.parse(uri_str).path
query = URI.parse(uri_str).query
Net::HTTP.start(host, port) {|http|
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
@ -80,10 +83,10 @@ def fetch(uri_str, limit = 10)
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