dav4rack 0.1.7 → 0.1.8
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +2 -0
- data/lib/dav4rack/controller.rb +1 -1
- data/lib/dav4rack/handler.rb +36 -34
- data/lib/dav4rack/resource.rb +1 -0
- data/lib/dav4rack/version.rb +1 -1
- metadata +4 -4
data/lib/dav4rack/controller.rb
CHANGED
@@ -122,7 +122,7 @@ module DAV4Rack
|
|
122
122
|
status = resource.copy(dest, overwrite)
|
123
123
|
else
|
124
124
|
raise Conflict unless depth.is_a?(Symbol) || depth > 1
|
125
|
-
status = resource.move(dest)
|
125
|
+
status = resource.move(dest, overwrite)
|
126
126
|
end
|
127
127
|
response['Location'] = "#{scheme}://#{host}:#{port}#{dest.public_path}" if status == Created
|
128
128
|
multistatus do |xml|
|
data/lib/dav4rack/handler.rb
CHANGED
@@ -15,45 +15,47 @@ module DAV4Rack
|
|
15
15
|
end
|
16
16
|
|
17
17
|
def call(env)
|
18
|
-
start = Time.now
|
19
|
-
request = Rack::Request.new(env)
|
20
|
-
response = Rack::Response.new
|
21
|
-
|
22
|
-
Logger.info "Processing WebDAV request: #{request.path} (for #{request.ip} at #{Time.now}) [#{request.request_method}]"
|
23
|
-
|
24
|
-
controller = nil
|
25
18
|
begin
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
19
|
+
start = Time.now
|
20
|
+
request = Rack::Request.new(env)
|
21
|
+
response = Rack::Response.new
|
22
|
+
|
23
|
+
Logger.info "Processing WebDAV request: #{request.path} (for #{request.ip} at #{Time.now}) [#{request.request_method}]"
|
24
|
+
|
25
|
+
controller = nil
|
26
|
+
begin
|
27
|
+
controller = Controller.new(request, response, @options.dup)
|
28
|
+
controller.authenticate
|
29
|
+
res = controller.send(request.request_method.downcase)
|
30
|
+
response.status = res.code if res.respond_to?(:code)
|
31
|
+
rescue HTTPStatus::Unauthorized => status
|
32
|
+
response.body = controller.resource.respond_to?(:authentication_error_msg) ? controller.resource.authentication_error_msg : 'Not Authorized'
|
33
|
+
response['WWW-Authenticate'] = "Basic realm=\"#{controller.resource.respond_to?(:authentication_realm) ? controller.resource.authentication_realm : 'Locked content'}\""
|
34
|
+
response.status = status.code
|
35
|
+
rescue HTTPStatus::Status => status
|
36
|
+
response.status = status.code
|
37
|
+
end
|
38
|
+
|
39
|
+
# Strings in Ruby 1.9 are no longer enumerable. Rack still expects the response.body to be
|
40
|
+
# enumerable, however.
|
41
|
+
|
42
|
+
response['Content-Length'] = response.body.to_s.length unless response['Content-Length'] || !response.body.is_a?(String)
|
43
|
+
response.body = [response.body] if not response.body.respond_to? :each
|
44
|
+
response.status = response.status ? response.status.to_i : 200
|
45
|
+
response.headers.keys.each{|k| response.headers[k] = response[k].to_s}
|
46
|
+
|
47
|
+
# Apache wants the body dealt with, so just read it and junk it
|
48
|
+
buf = true
|
49
|
+
buf = request.body.read(8192) while buf
|
50
|
+
|
51
|
+
Logger.debug "Response in string form. Outputting contents: \n#{response.body}" if response.body.is_a?(String)
|
52
|
+
Logger.info "Completed in: #{((Time.now.to_f - start.to_f) * 1000).to_i} ms | #{response.status} [#{request.url}]"
|
53
|
+
|
54
|
+
response.body.is_a?(Rack::File) ? response.body.call(env) : response.finish
|
36
55
|
rescue Exception => e
|
37
56
|
Logger.error "WebDAV Error: #{e}\n#{e.backtrace.join("\n")}"
|
38
57
|
raise e
|
39
58
|
end
|
40
|
-
|
41
|
-
# Strings in Ruby 1.9 are no longer enumerable. Rack still expects the response.body to be
|
42
|
-
# enumerable, however.
|
43
|
-
|
44
|
-
response['Content-Length'] = response.body.to_s.length unless response['Content-Length'] || !response.body.is_a?(String)
|
45
|
-
response.body = [response.body] if not response.body.respond_to? :each
|
46
|
-
response.status = response.status ? response.status.to_i : 200
|
47
|
-
response.headers.keys.each{|k| response.headers[k] = response[k].to_s}
|
48
|
-
|
49
|
-
# Apache wants the body dealt with, so just read it and junk it
|
50
|
-
buf = true
|
51
|
-
buf = request.body.read(8192) while buf
|
52
|
-
|
53
|
-
Logger.debug "Response in string form. Outputting contents: \n#{response.body}" if response.body.is_a?(String)
|
54
|
-
Logger.info "Completed in: #{((Time.now.to_f - start.to_f) * 1000).to_i} ms | #{response.status} [#{request.url}]"
|
55
|
-
|
56
|
-
response.body.is_a?(Rack::File) ? response.body.call(env) : response.finish
|
57
59
|
end
|
58
60
|
|
59
61
|
end
|
data/lib/dav4rack/resource.rb
CHANGED
data/lib/dav4rack/version.rb
CHANGED
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dav4rack
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 11
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 1
|
9
|
-
-
|
10
|
-
version: 0.1.
|
9
|
+
- 8
|
10
|
+
version: 0.1.8
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Chris Roberts
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2010-
|
18
|
+
date: 2010-12-17 00:00:00 -08:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|