Module: Capcode::Helpers

Defined in:
lib/capcode/render/webdav.rb

Instance Method Summary collapse

Instance Method Details

#render_webdav(f, opts) ⇒ Object



23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/capcode/render/webdav.rb', line 23

def render_webdav( f, opts )
  options = {
    :resource_class => RackDAV::FileResource,
    :root => f
  }.merge(opts)
  		
  request = Rack::Request.new(env)
  response = Rack::Response.new
  
  begin
    controller = RackDAV::Controller.new(request, response, options.dup)		    
    controller.send(request.request_method.downcase)
  rescue RackDAV::HTTPStatus::Status => status
    response.status = status.code
  end
    
  # Strings in Ruby 1.9 are no longer enumerable.  Rack still expects the response.body to be
  # enumerable, however.
  response.body = [response.body] if not response.body.respond_to? :each
    
  response.status = response.status ? response.status.to_i : 200
  response.finish
  
  [response.status, response.header, response.body]
end