fix voor ssl
This commit is contained in:
parent
6a6d42f402
commit
6fa1a57fda
1 changed files with 30 additions and 18 deletions
|
|
@ -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,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
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue