Sha256: 2ec066997bc01229562722b31bcaed1e952cd0acc9cf0b71c3016ccd7570a490

Contents?: true

Size: 1.14 KB

Versions: 3

Compression:

Stored size: 1.14 KB

Contents

# From rack_dav
require 'builder'
require 'time'
require 'uri'
require 'rexml/document'
require 'webrick/httputils'
 
require 'rack_dav/builder_namespace'
require 'rack_dav/http_status'
require 'rack_dav/resource'
require 'rack_dav/file_resource'
require 'rack_dav/handler'
require 'rack_dav/controller'


module Capcode
  module Helpers
    
    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
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
Capcode-0.8.7 lib/capcode/render/webdav.rb
Capcode-0.8.6 lib/capcode/render/webdav.rb
Capcode-0.8.5 lib/capcode/render/webdav.rb