Tôi muốn kiểm tra xem URI sẽ cần chứng thực SSL:Ruby: Kiểm tra xem URI có phải là HTTPS không?
url = URI.parse("http://www.google.com")
# [some code]
if url.instance_of? URI::HTTPS
http.use_ssl=true
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
end
Tuy nhiên, những vài dòng ném các lỗi sau ..
/usr/lib/ruby/1.8/uri/common.rb:436:in `split': bad URI(is not URI?): HTTPS (URI::InvalidURIError)
from /usr/lib/ruby/1.8/uri/common.rb:485:in `parse'
from /usr/lib/ruby/1.8/uri/common.rb:608:in `URI'
from links.rb:18
Tại sao nó xảy ra?
Nhân tiện, https://mislav.net/2013/07/ruby-openssl/ giải thích tại sao «OpenSSL :: SSL :: VERIFY_NONE' không phải là lựa chọn tốt nhất –