net_dav 0.2.1 → 0.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/VERSION +1 -1
- data/bin/dav +14 -2
- data/lib/net/dav.rb +32 -1
- data/net_dav.gemspec +3 -2
- data/script/multi-test +54 -0
- metadata +3 -2
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.2.
|
1
|
+
0.2.2
|
data/bin/dav
CHANGED
@@ -36,9 +36,21 @@ else
|
|
36
36
|
url = URI.parse $*[1]
|
37
37
|
end
|
38
38
|
|
39
|
-
enable_curl = !ENV['DISABLE_CURL']
|
39
|
+
enable_curl = !(ENV['DISABLE_CURL'] && ENV['DISABLE_CURL'] != "0")
|
40
40
|
|
41
|
-
|
41
|
+
dav = Net::DAV.new(url, :curl => enable_curl)
|
42
|
+
|
43
|
+
if (url.scheme == 'https')
|
44
|
+
dav.verify_callback = lambda do |preverify_ok, x509_store|
|
45
|
+
puts "preverify = #{preverify_ok}" if $DEBUG
|
46
|
+
puts "cert = #{x509_store.current_cert.inspect}" if $DEBUG
|
47
|
+
preverify_ok
|
48
|
+
end
|
49
|
+
|
50
|
+
dav.verify_server = false
|
51
|
+
end
|
52
|
+
|
53
|
+
res = dav.start { |dav|
|
42
54
|
dav.credentials(dav_user, dav_pass) if dav_user
|
43
55
|
case cmd
|
44
56
|
when 'put'
|
data/lib/net/dav.rb
CHANGED
@@ -15,13 +15,23 @@ module Net #:nodoc:
|
|
15
15
|
class NetHttpHandler
|
16
16
|
attr_writer :user, :pass
|
17
17
|
|
18
|
+
def verify_callback=(callback)
|
19
|
+
@http.verify_callback = callback
|
20
|
+
end
|
21
|
+
|
22
|
+
def verify_server=(value)
|
23
|
+
@http.verify_mode = value ? OpenSSL::SSL::VERIFY_PEER : OpenSSL::SSL::VERIFY_NONE
|
24
|
+
end
|
25
|
+
|
18
26
|
def initialize(uri)
|
19
27
|
@uri = uri
|
20
28
|
case @uri.scheme
|
21
29
|
when "http"
|
22
30
|
@http = Net::HTTP.new(@uri.host, @uri.port)
|
23
31
|
when "https"
|
24
|
-
@http = Net::
|
32
|
+
@http = Net::HTTP.new(@uri.host, @uri.port)
|
33
|
+
@http.use_ssl = true
|
34
|
+
self.verify_server = true
|
25
35
|
else
|
26
36
|
raise "unknown uri scheme"
|
27
37
|
end
|
@@ -158,6 +168,19 @@ module Net #:nodoc:
|
|
158
168
|
|
159
169
|
|
160
170
|
class CurlHandler < NetHttpHandler
|
171
|
+
def verify_callback=(callback)
|
172
|
+
super
|
173
|
+
curl = make_curl
|
174
|
+
$stderr.puts "verify_callback not implemented in Curl::Easy"
|
175
|
+
end
|
176
|
+
|
177
|
+
def verify_server=(value)
|
178
|
+
super
|
179
|
+
curl = make_curl
|
180
|
+
curl.ssl_verify_peer = value
|
181
|
+
curl.ssl_verify_host = value
|
182
|
+
end
|
183
|
+
|
161
184
|
def make_curl
|
162
185
|
unless @curl
|
163
186
|
@curl = Curl::Easy.new
|
@@ -357,5 +380,13 @@ module Net #:nodoc:
|
|
357
380
|
res.body
|
358
381
|
end
|
359
382
|
|
383
|
+
def verify_callback=(callback)
|
384
|
+
@handler.verify_callback = callback
|
385
|
+
end
|
386
|
+
|
387
|
+
def verify_server=(value)
|
388
|
+
@handler.verify_server = value
|
389
|
+
end
|
390
|
+
|
360
391
|
end
|
361
392
|
end
|
data/net_dav.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{net_dav}
|
8
|
-
s.version = "0.2.
|
8
|
+
s.version = "0.2.2"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Miron Cuperman"]
|
12
|
-
s.date = %q{2009-
|
12
|
+
s.date = %q{2009-11-01}
|
13
13
|
s.default_executable = %q{dav}
|
14
14
|
s.description = %q{WebDAV client library in the style of Net::HTTP}
|
15
15
|
s.email = %q{c1.github@niftybox.net}
|
@@ -29,6 +29,7 @@ Gem::Specification.new do |s|
|
|
29
29
|
"lib/net/dav.rb",
|
30
30
|
"lib/net/dav/item.rb",
|
31
31
|
"net_dav.gemspec",
|
32
|
+
"script/multi-test",
|
32
33
|
"spec/net_dav_spec.rb",
|
33
34
|
"spec/spec.opts",
|
34
35
|
"spec/spec_helper.rb",
|
data/script/multi-test
ADDED
@@ -0,0 +1,54 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'zlib'
|
4
|
+
require 'uri'
|
5
|
+
require 'rubygems'
|
6
|
+
require 'net/dav'
|
7
|
+
|
8
|
+
url = URI.parse $*[0]
|
9
|
+
|
10
|
+
items = []
|
11
|
+
reps = 10
|
12
|
+
nthreads = 10
|
13
|
+
use_curl = true
|
14
|
+
use_curl = false if ENV['DISABLE_CURL']
|
15
|
+
|
16
|
+
Net::DAV.start(url, :curl => use_curl) do |dav|
|
17
|
+
dav.find(url.path) do |item|
|
18
|
+
items << item
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
curindex = 0
|
23
|
+
nitems = items.size / nthreads + 1
|
24
|
+
nitems = 1 if nitems < 1
|
25
|
+
threads = []
|
26
|
+
(1..nthreads).each do |tind|
|
27
|
+
next if curindex >= items.size
|
28
|
+
titems = items[curindex, nitems]
|
29
|
+
curindex += nitems
|
30
|
+
threads << Thread.new(tind, titems) do |tind, titems|
|
31
|
+
Net::DAV.start(url, :curl => use_curl) do |dav|
|
32
|
+
Thread.current.abort_on_exception = true
|
33
|
+
crcs = {}
|
34
|
+
(1..reps).each do
|
35
|
+
titems.each do |item|
|
36
|
+
total_size = 0
|
37
|
+
crc = 0
|
38
|
+
dav.get(item.uri.path) do |str|
|
39
|
+
#puts "get #{item.uri} #{total_size}"
|
40
|
+
total_size += str.length
|
41
|
+
crc = Zlib.crc32(str, crc)
|
42
|
+
end
|
43
|
+
puts "[#{tind}] new crc for #{item.uri}" if (crcs[item.uri].nil?)
|
44
|
+
crcs[item.uri] = crc if (crcs[item.uri].nil?)
|
45
|
+
raise "crc mismatch #{item} #{crc} #{crcs[item.uri]}" if (crc != crcs[item.uri])
|
46
|
+
raise "size mismatch #{item} #{item.size} #{total_size}" if (total_size != item.size)
|
47
|
+
puts "[#{tind}] good #{item.uri} #{item.size} #{crc}"
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
threads.each { |thread| thread.join }
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: net_dav
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Miron Cuperman
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-
|
12
|
+
date: 2009-11-01 00:00:00 -07:00
|
13
13
|
default_executable: dav
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
@@ -52,6 +52,7 @@ files:
|
|
52
52
|
- lib/net/dav.rb
|
53
53
|
- lib/net/dav/item.rb
|
54
54
|
- net_dav.gemspec
|
55
|
+
- script/multi-test
|
55
56
|
- spec/net_dav_spec.rb
|
56
57
|
- spec/spec.opts
|
57
58
|
- spec/spec_helper.rb
|