From cfe41e916659ccccc81a32d99a1d786a29fe1578 Mon Sep 17 00:00:00 2001 From: zedshaw Date: Sat, 12 Aug 2006 23:12:46 +0000 Subject: Fixes redirects not working with new unlocked IO, becase Matt P. showed me I'm a lame moron. git-svn-id: svn+ssh://rubyforge.org/var/svn/mongrel/trunk@320 19e92222-5c0b-0410-8929-a290d50e31e9 --- lib/mongrel/cgi.rb | 6 ++++++ lib/mongrel/configurator.rb | 17 +++++++++++++---- lib/mongrel/rails.rb | 2 +- 3 files changed, 20 insertions(+), 5 deletions(-) (limited to 'lib/mongrel') diff --git a/lib/mongrel/cgi.rb b/lib/mongrel/cgi.rb index 62214d2..b327def 100644 --- a/lib/mongrel/cgi.rb +++ b/lib/mongrel/cgi.rb @@ -85,6 +85,7 @@ module Mongrel options.each{|k,v| @head[k] = v} end + STDERR.puts "HEADER: #{@head.inspect}" # doing this fakes out the cgi library to think the headers are empty # we then do the real headers in the out function call later "" @@ -132,12 +133,16 @@ module Mongrel header(options) + STDERR.puts "RAILS: #{options.inspect}, HEADER: #{@head.inspect}" + @response.start status do |head, body| send_cookies(head) @head.each {|k,v| head[k] = v} body.write(yield || "") end + + @out_called = true end # Computes the status once, but lazily so that people who call header twice @@ -151,6 +156,7 @@ module Mongrel @status = stat || "200" end + STDERR.puts "STATUS: #{@status} from HEAD: #{@head["Status"]}" @status end diff --git a/lib/mongrel/configurator.rb b/lib/mongrel/configurator.rb index 94cd6e9..78895b9 100644 --- a/lib/mongrel/configurator.rb +++ b/lib/mongrel/configurator.rb @@ -149,7 +149,7 @@ module Mongrel # * :in_front => true/false -- Rather than appending, it prepends this handler. def uri(location, options={}) ops = resolve_defaults(options) - @listener.register(location, ops[:handler], in_front=ops[:in_front]) + @listener.register(location, ops[:handler], ops[:in_front]) end @@ -173,7 +173,16 @@ module Mongrel if RUBY_PLATFORM !~ /mswin/ require 'daemons/daemonize' - Daemonize.daemonize(log_file=ops[:log_file]) + logfile = ops[:log_file] + if logfile[0].chr != "/" + logfile = File.join(ops[:cwd],logfile) + if not File.exist?(File.dirname(logfile)) + log "!!! Log file directory not found at full path #{File.dirname(logfile)}. Update your configuration to use a full path." + exit 1 + end + end + + Daemonize.daemonize(logfile) # change back to the original starting directory Dir.chdir(ops[:cwd]) @@ -339,7 +348,7 @@ module Mongrel ops = resolve_defaults(options) # forced shutdown, even if previously restarted (actually just like TERM but for CTRL-C) - trap("INT") { log "INT signal received."; stop(need_restart=false) } + trap("INT") { log "INT signal received."; stop(false) } # clean up the pid file always at_exit { File.unlink(@pid_file) if @pid_file and File.exists?(@pid_file) } @@ -349,7 +358,7 @@ module Mongrel trap("TERM") { log "TERM signal received."; stop } # restart - trap("USR2") { log "USR2 signal received."; stop(need_restart=true) } + trap("USR2") { log "USR2 signal received."; stop(true) } log "Signals ready. TERM => stop. USR2 => restart. INT => stop (no restart)." else diff --git a/lib/mongrel/rails.rb b/lib/mongrel/rails.rb index 8d7dd39..3894d2d 100644 --- a/lib/mongrel/rails.rb +++ b/lib/mongrel/rails.rb @@ -76,7 +76,7 @@ module Mongrel unlock! # This finalizes the output using the proper HttpResponse way - cgi.out(really_final=true) {""} + cgi.out("text/html",true) {""} rescue Errno::EPIPE # ignored rescue Object => rails_error -- cgit v1.2.3-24-ge0c7