mirror of
https://github.com/puma/puma.git
synced 2022-11-09 13:48:40 -05:00
Minor tweaks to the handlers and http parser to deal with more bad input possibilities.
git-svn-id: svn+ssh://rubyforge.org/var/svn/mongrel/trunk@139 19e92222-5c0b-0410-8929-a290d50e31e9
This commit is contained in:
parent
3c804d5e15
commit
5d600bfd24
4 changed files with 35 additions and 5 deletions
19
examples/random_thrash.rb
Normal file
19
examples/random_thrash.rb
Normal file
|
@ -0,0 +1,19 @@
|
|||
require 'socket'
|
||||
devrand = open("/dev/random","r")
|
||||
|
||||
loop do
|
||||
s = TCPSocket.new(ARGV[0],ARGV[1])
|
||||
s.write("GET / HTTP/1.1\r\n")
|
||||
total = 0
|
||||
begin
|
||||
loop do
|
||||
r = devrand.read(10)
|
||||
n = s.write(r)
|
||||
total += n
|
||||
end
|
||||
rescue Object
|
||||
STDERR.puts "#$!: #{total}"
|
||||
end
|
||||
s.close
|
||||
sleep 1
|
||||
end
|
|
@ -124,10 +124,20 @@ void header_done(void *data, const char *at, size_t length)
|
|||
VALUE temp = Qnil;
|
||||
VALUE host = Qnil;
|
||||
VALUE port = Qnil;
|
||||
VALUE ctype = Qnil;
|
||||
VALUE clen = Qnil;
|
||||
char *colon = NULL;
|
||||
|
||||
rb_hash_aset(req, global_content_length, rb_hash_aref(req, global_http_content_length));
|
||||
rb_hash_aset(req, global_content_type, rb_hash_aref(req, global_http_content_type));
|
||||
clen = rb_hash_aref(req, global_http_content_length);
|
||||
if(clen != Qnil) {
|
||||
rb_hash_aset(req, global_content_length, clen);
|
||||
}
|
||||
|
||||
ctype = rb_hash_aref(req, global_http_content_type);
|
||||
if(ctype != Qnil) {
|
||||
rb_hash_aset(req, global_content_type, Qnil);
|
||||
}
|
||||
|
||||
rb_hash_aset(req, global_gateway_interface, global_gateway_interface_value);
|
||||
if((temp = rb_hash_aref(req, global_http_host)) != Qnil) {
|
||||
// ruby better close strings off with a '\0' dammit
|
||||
|
|
|
@ -169,7 +169,7 @@ module Mongrel
|
|||
ext = req[dot_at .. -1]
|
||||
if MIME_TYPES[ext]
|
||||
stat = File.stat(req)
|
||||
response.header[Const::CONTENT_TYPE] = MIME_TYPES[ext]
|
||||
response.header[Const::CONTENT_TYPE] = MIME_TYPES[ext] || "text"
|
||||
# TODO: Confirm this works for rfc 1123
|
||||
response.header[Const::LAST_MODIFIED] = HttpServer.httpdate(stat.mtime)
|
||||
# TODO that this is a valid way to calculate an etag
|
||||
|
@ -187,7 +187,7 @@ module Mongrel
|
|||
else
|
||||
File.open(req, "rb") { |f| response.socket.write(f.read) }
|
||||
end
|
||||
rescue EOFError,Errno::ECONNRESET,Errno::EPIPE
|
||||
rescue EOFError,Errno::ECONNRESET,Errno::EPIPE,Errno::EINVAL
|
||||
# ignore these since it means the client closed off early
|
||||
end
|
||||
else
|
||||
|
|
|
@ -132,7 +132,8 @@ module Mongrel
|
|||
|
||||
$orig_dollar_quote = $".clone
|
||||
ENV['RAILS_ENV'] = ops[:environment]
|
||||
require "#{ops[:cwd]}/config/environment"
|
||||
env_location = "#{ops[:cwd]}/config/environment"
|
||||
require env_location
|
||||
require 'dispatcher'
|
||||
require 'mongrel/rails'
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue