lib/net/dav.rb in net_dav-0.2.1 vs lib/net/dav.rb in net_dav-0.2.2
- old
+ new
@@ -13,17 +13,27 @@
class DAV
MAX_REDIRECTS = 10
class NetHttpHandler
attr_writer :user, :pass
+ def verify_callback=(callback)
+ @http.verify_callback = callback
+ end
+
+ def verify_server=(value)
+ @http.verify_mode = value ? OpenSSL::SSL::VERIFY_PEER : OpenSSL::SSL::VERIFY_NONE
+ end
+
def initialize(uri)
@uri = uri
case @uri.scheme
when "http"
@http = Net::HTTP.new(@uri.host, @uri.port)
when "https"
- @http = Net::HTTPS.new(@uri.host, @uri.port)
+ @http = Net::HTTP.new(@uri.host, @uri.port)
+ @http.use_ssl = true
+ self.verify_server = true
else
raise "unknown uri scheme"
end
end
@@ -156,10 +166,23 @@
end
end
class CurlHandler < NetHttpHandler
+ def verify_callback=(callback)
+ super
+ curl = make_curl
+ $stderr.puts "verify_callback not implemented in Curl::Easy"
+ end
+
+ def verify_server=(value)
+ super
+ curl = make_curl
+ curl.ssl_verify_peer = value
+ curl.ssl_verify_host = value
+ end
+
def make_curl
unless @curl
@curl = Curl::Easy.new
@curl.timeout = @http.read_timeout
@curl.follow_location = true
@@ -353,9 +376,17 @@
# Makes a new directory (collection)
def mkdir(path)
res = @handler.request(:mkcol, path, nil, nil)
res.body
+ end
+
+ def verify_callback=(callback)
+ @handler.verify_callback = callback
+ end
+
+ def verify_server=(value)
+ @handler.verify_server = value
end
end
end