diff options
author | zedshaw <zedshaw@19e92222-5c0b-0410-8929-a290d50e31e9> | 2006-08-11 18:46:33 +0000 |
---|---|---|
committer | zedshaw <zedshaw@19e92222-5c0b-0410-8929-a290d50e31e9> | 2006-08-11 18:46:33 +0000 |
commit | d5b23a5a61568e51ca89adfc86d0f42fd27cee5d (patch) | |
tree | 0b51becbd357b824d92ad10645d84254fddc79e4 | |
parent | ee675d5a703efaab60ef90a8b41f87348d928db7 (diff) | |
download | unicorn-d5b23a5a61568e51ca89adfc86d0f42fd27cee5d.tar.gz |
git-svn-id: svn+ssh://rubyforge.org/var/svn/mongrel/trunk@312 19e92222-5c0b-0410-8929-a290d50e31e9
-rw-r--r-- | bin/mongrel_rails | 9 | ||||
-rw-r--r-- | ext/http11/http11_parser.rl | 2 | ||||
-rw-r--r-- | lib/mongrel.rb | 18 | ||||
-rw-r--r-- | lib/mongrel/configurator.rb | 1 |
4 files changed, 17 insertions, 13 deletions
diff --git a/bin/mongrel_rails b/bin/mongrel_rails index 310ee6e..dd90356 100644 --- a/bin/mongrel_rails +++ b/bin/mongrel_rails @@ -69,6 +69,7 @@ class Start < GemPlugin::Plugin "/commands" :user => @user, :group => @group, :prefix => @prefix } + if @generate STDERR.puts "** Writing config to #@generate" open(@generate, "w") {|f| f.write(settings.to_yaml) } @@ -77,9 +78,9 @@ class Start < GemPlugin::Plugin "/commands" end if @config_file - STDERR.puts "** Loading settings from #{@config_file} (they override command line)." unless settings[:daemon] conf = YAML.load_file(@config_file) settings = settings.merge! conf + STDERR.puts "** Loading settings from #{@config_file} (they override command line)." unless settings[:daemon] end config = Mongrel::Rails::RailsConfigurator.new(settings) do @@ -127,10 +128,10 @@ class Start < GemPlugin::Plugin "/commands" config.run config.log "Mongrel available at #{settings[:host]}:#{settings[:port]}" - if not @daemon - config.log "Use CTRL-C to stop." - else + if config.defaults[:daemon] config.write_pid_file + else + config.log "Use CTRL-C to stop." end config.join diff --git a/ext/http11/http11_parser.rl b/ext/http11/http11_parser.rl index e3543c1..ce9d905 100644 --- a/ext/http11/http11_parser.rl +++ b/ext/http11/http11_parser.rl @@ -106,7 +106,7 @@ field_value = any* >start_value %write_value; - message_header = field_name ": " field_value :> CRLF; + message_header = field_name ":" " "* field_value :> CRLF; Request = Request_Line (message_header)* ( CRLF @done); diff --git a/lib/mongrel.rb b/lib/mongrel.rb index a4ca700..7349dae 100644 --- a/lib/mongrel.rb +++ b/lib/mongrel.rb @@ -194,7 +194,8 @@ module Mongrel dispatcher.request_begins(params) if dispatcher - if remain == 0 + # Some clients (like FF1.0) report 0 for body and then send a body. This will probably truncate them but at least the request goes through usually. + if remain <= 0 # we've got everything, pack it up @body = StringIO.new @body.write params.http_body @@ -416,17 +417,18 @@ module Mongrel end # Appends the contents of +path+ to the response stream. The file is opened for binary - # reading and written in chunks to the socket. If the - # <a href="http://rubyforge.org/projects/ruby-sendfile">sendfile</a> library is found, - # it is used to send the file, often with greater speed and less memory/cpu usage. + # reading and written in chunks to the socket. # - # The presence of ruby-sendfile is determined by @socket.response_to? :sendfile, which means - # that if you have your own sendfile implementation you can use it without changing this function, - # just make sure it follows the ruby-sendfile signature. + # Sendfile API support has been removed in 0.3.13.4 due to stability problems. def send_file(path) File.open(path, "rb") do |f| while chunk = f.read(Const::CHUNK_SIZE) and chunk.length > 0 - write(chunk) + begin + write(chunk) + rescue Object => exc + # TODO: find out if people care about failures to write these files + break + end end @body_sent = true end diff --git a/lib/mongrel/configurator.rb b/lib/mongrel/configurator.rb index cd4ca9a..94cd6e9 100644 --- a/lib/mongrel/configurator.rb +++ b/lib/mongrel/configurator.rb @@ -73,6 +73,7 @@ module Mongrel # Writes the PID file but only if we're on windows. def write_pid_file if RUBY_PLATFORM !~ /mswin/ + log "Writing PID file to #{@pid_file}" open(@pid_file,"w") {|f| f.write(Process.pid) } end end |