basic authentication ook laten werken
This commit is contained in:
parent
dd33751ebc
commit
19040f3a9c
1 changed files with 25 additions and 2 deletions
|
|
@ -274,6 +274,8 @@ Usage: #{$0.sub(/.*\//, "")} [options] -u <baseurl>
|
|||
-m <svn|cvs|git|ds> check for one of subversion, CVS, git or .DS_Store (default: all)
|
||||
-u <baseurl> set baseurl
|
||||
-s use ssl
|
||||
--user <user> basic authentiction user
|
||||
--pass <password> basic authentication password
|
||||
EOT
|
||||
exit
|
||||
end
|
||||
|
|
@ -286,7 +288,9 @@ def cmdline
|
|||
[ "-H", GetoptLong::NO_ARGUMENT ],
|
||||
[ "-m", GetoptLong::REQUIRED_ARGUMENT ],
|
||||
[ "-u", GetoptLong::REQUIRED_ARGUMENT ],
|
||||
[ "-s", GetoptLong::NO_ARGUMENT ]
|
||||
[ "-s", GetoptLong::NO_ARGUMENT ],
|
||||
[ "--user", GetoptLong::REQUIRED_ARGUMENT ],
|
||||
[ "--pass", GetoptLong::REQUIRED_ARGUMENT ]
|
||||
)
|
||||
opts.quiet=true
|
||||
|
||||
|
|
@ -323,6 +327,16 @@ def fetch(uri_str, limit = 10)
|
|||
port = URI.parse(uri_str).port
|
||||
path = URI.parse(uri_str).path
|
||||
query = URI.parse(uri_str).query
|
||||
userinfo = URI.parse(uri_str).userinfo
|
||||
user = ""
|
||||
pass = ""
|
||||
|
||||
if userinfo
|
||||
user, pass = userinfo.split(/:/)
|
||||
end
|
||||
|
||||
user = @user if @user
|
||||
pass = @pass if @pass
|
||||
|
||||
http = Net::HTTP.new(host, port)
|
||||
http.use_ssl = @use_ssl
|
||||
|
|
@ -331,7 +345,8 @@ def fetch(uri_str, limit = 10)
|
|||
else
|
||||
req = Net::HTTP::Get.new("#{URI.escape(path)}")
|
||||
end
|
||||
req.basic_auth @user, @pass
|
||||
|
||||
req.basic_auth user, pass
|
||||
response = http.request(req)
|
||||
case response
|
||||
when Net::HTTPSuccess then response.body
|
||||
|
|
@ -638,6 +653,14 @@ else
|
|||
@use_ssl = false
|
||||
end
|
||||
|
||||
if options["--user"]
|
||||
@user = options["--user"]
|
||||
end
|
||||
|
||||
if options["--pass"]
|
||||
@pass = options["--pass"]
|
||||
end
|
||||
|
||||
# lelijke hack, wanneer andere formaten ook geharvest gaan kunnen worden moet dit
|
||||
# anders. Nu, ach, dit werkt.
|
||||
if options["-H"]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue