Sha256: 7efddd360e1712e9d94b5e51832f5a5f73ea7070a970d0c9fd30f0749f4ae7e2
Contents?: true
Size: 1.32 KB
Versions: 1
Compression:
Stored size: 1.32 KB
Contents
module DAV4Rack class Handler include DAV4Rack::HTTPStatus def initialize(options={}) @options = options.dup unless(@options[:resource_class]) require 'dav4rack/file_resource' @options[:resource_class] = FileResource @options[:root] ||= Dir.pwd end end def call(env) request = Rack::Request.new(env) response = Rack::Response.new begin controller = Controller.new(request, response, @options.dup) res = controller.send(request.request_method.downcase) response.status = res.code if res.respond_to?(:code) rescue 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['Content-Length'] = response.body.to_s.length unless response['Content-Length'] || response.body.empty? response.body = [response.body] if not response.body.respond_to? :each response.status = response.status ? response.status.to_i : 200 response.headers.each_pair{|k,v| response[k] = v.to_s} # Apache wants the body dealt with, so just read it and junk it buf = true buf = request.body.read(8192) while buf response.finish end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
dav4rack-0.0.1 | lib/dav4rack/handler.rb |