我正在尝试用我更喜欢的东西替换我的红宝石中的一些贝壳卷曲,例如“打开 - 尿”,但是失败并得到:' 401需要授权'
我试图替换它:
status = system("curl -Is -w '%{http_code}\\n' --digest -u #{usr}:#{psw} https://#{source}/ -o /dev/null")
有了这个:
require 'open-uri'
status = open("https://#{source}/", :http_basic_authentication=>[usr, psw])
但仍然得到401.任何想法? 谢谢
答案 0 :(得分:2)
如果您点击了任何重定向,this could be your problem:
if redirect
...
if options.include? :http_basic_authentication
# send authentication only for the URI directly specified.
options = options.dup
options.delete :http_basic_authentication
end
end