Changeset 1039
- Timestamp:
- 11/23/07 14:07:06 (1 year ago)
- Files:
-
- trunk/Rakefile (modified) (2 diffs)
- trunk/app_generators/merb/templates/config/merb.yml (modified) (1 diff)
- trunk/lib/merb/mongrel_handler.rb (modified) (2 diffs)
- trunk/lib/merb/server.rb (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/Rakefile
r1038 r1039 19 19 20 20 21 @windows = (PLATFORM =~ /win32/)21 windows = (PLATFORM =~ /win32/) 22 22 23 SUDO = @windows ? "" : (ENV["SUDO_COMMAND"] && "sudo")23 SUDO = windows ? "" : "sudo" 24 24 25 25 setup_clean [ "pkg", "lib/*.bundle", "*.gem", "doc/rdoc", ".config", 'coverage', "cache"] … … 93 93 task :doc_rforge do 94 94 sh %{rake doc} 95 sh %{#{SUDO} chmod -R 755 doc} unless @windows95 sh %{#{SUDO} chmod -R 755 doc} unless windows 96 96 sh %{/usr/bin/scp -r -p doc/rdoc/* ezmobius@rubyforge.org:/var/www/gforge-projects/merb} 97 97 end trunk/app_generators/merb/templates/config/merb.yml
r727 r1039 33 33 #:cache_templates: true 34 34 35 # this is true if you want mongrel to emulate the X-Sendfile header internally, 36 # false if you want it to fall thru to apache or whatever front end server you use. 37 # true by default 38 #:mongrel_x_sendfile: false 39 35 40 # Uncomment and set this if you want to run a drb server for upload progress 36 41 # or other drb services. trunk/lib/merb/mongrel_handler.rb
r1038 r1039 27 27 # directory of your site. This is set to the root of your merb app + '/public' 28 28 # by default. 29 def initialize(dir, opts = {})29 def initialize(dir, mongrel_x_sendfile=true, opts = {}) 30 30 @files = Mongrel::DirHandler.new(dir,false) 31 @mongrel_x_sendfile = mongrel_x_sendfile 31 32 end 32 33 … … 108 109 109 110 if sendfile 110 benchmarks[:sendfile_time] = Time.now - start 111 MERB_LOGGER.info("X-SENDFILE: #{sendfile}\nComplete Request took: #{ 112 benchmarks[:sendfile_time]} seconds") 113 file_status = File.stat(sendfile) 114 response.status = 200 115 # Set the last modified times as well and etag for all files 116 response.header[Mongrel::Const::LAST_MODIFIED] = file_status.mtime.httpdate 117 # Calculated the same as apache, not sure how well the works on win32 118 response.header[Mongrel::Const::ETAG] = Mongrel::Const::ETAG_FORMAT % [file_status.mtime.to_i, file_status.size, file_status.ino] 119 # Send a status with out content length 120 response.send_status(file_status.size) 121 response.send_header 122 response.send_file(sendfile) 111 if @mongrel_x_sendfile 112 # we want to emulate X-Sendfile header internally in mongrel 113 benchmarks[:sendfile_time] = Time.now - start 114 MERB_LOGGER.info("X-SENDFILE: #{sendfile}\nComplete Request took: #{ 115 benchmarks[:sendfile_time]} seconds") 116 file_status = File.stat(sendfile) 117 response.status = 200 118 # Set the last modified times as well and etag for all files 119 response.header[Mongrel::Const::LAST_MODIFIED] = file_status.mtime.httpdate 120 # Calculated the same as apache, not sure how well the works on win32 121 response.header[Mongrel::Const::ETAG] = Mongrel::Const::ETAG_FORMAT % [file_status.mtime.to_i, file_status.size, file_status.ino] 122 # Send a status with out content length 123 response.send_status(file_status.size) 124 response.send_header 125 response.send_file(sendfile) 126 else 127 # we want to pass thru the X-Sendfile header so apache or whatever 128 # front server can handle it 129 response.header['X-Sendfile'] = sendfile 130 response.header['Content-length'] = clength || File.size(sendfile) 131 response.finished 132 end 123 133 elsif controller.body.respond_to? :read 124 134 response.send_status(clength) trunk/lib/merb/server.rb
r1015 r1039 20 20 :use_mutex => true, 21 21 :session_id_cookie_only => true, 22 :query_string_whitelist => [] 22 :query_string_whitelist => [], 23 :mongrel_x_sendfile => true 23 24 } 24 25 end … … 604 605 listener do 605 606 uri( "/", :handler => MerbUploadHandler.new(@@merb_opts), :in_front => true) if @@merb_opts[:upload_path_match] 606 uri "/", :handler => MerbHandler.new(@@merb_opts[:merb_root]+'/public' )607 uri "/", :handler => MerbHandler.new(@@merb_opts[:merb_root]+'/public', @@merb_opts[:mongrel_x_sendfile]) 607 608 uri "/favicon.ico", :handler => Mongrel::Error404Handler.new("") 608 609 end
