mirror of
https://github.com/puma/puma.git
synced 2022-11-09 13:48:40 -05:00
Whitelist for headers which can be duplicated.
git-svn-id: svn+ssh://rubyforge.org/var/svn/mongrel/trunk@470 19e92222-5c0b-0410-8929-a290d50e31e9
This commit is contained in:
parent
4a3f4095b6
commit
0d2428d0f4
5 changed files with 27 additions and 4 deletions
2
Rakefile
2
Rakefile
|
@ -53,7 +53,7 @@ task :site => [:site_webgen, :site_rdoc, :site_coverage, :site_projects_rdoc]
|
|||
setup_extension("http11", "http11")
|
||||
|
||||
name="mongrel"
|
||||
version="0.3.19"
|
||||
version="0.3.20"
|
||||
|
||||
setup_gem(name, version) do |spec|
|
||||
spec.summary = "A small fast HTTP library and server that runs Rails, Camping, Nitro and Iowa apps."
|
||||
|
|
|
@ -84,6 +84,8 @@ module Mongrel
|
|||
if defaults[:daemon]
|
||||
if File.exist? defaults[:pid_file]
|
||||
log "!!! PID file #{defaults[:pid_file]} already exists. Mongrel could be running already. Check your #{defaults[:log_file]} for errors."
|
||||
log "!!! Exiting with error. You must stop mongrel and clear the .pid before I'll attempt a start."
|
||||
exit 1
|
||||
end
|
||||
|
||||
daemonize
|
||||
|
|
|
@ -556,7 +556,7 @@ void Init_http11()
|
|||
DEF_GLOBAL(server_protocol, "SERVER_PROTOCOL");
|
||||
DEF_GLOBAL(server_protocol_value, "HTTP/1.1");
|
||||
DEF_GLOBAL(http_host, "HTTP_HOST");
|
||||
DEF_GLOBAL(mongrel_version, "Mongrel 0.3.19");
|
||||
DEF_GLOBAL(mongrel_version, "Mongrel 0.3.20");
|
||||
DEF_GLOBAL(server_software, "SERVER_SOFTWARE");
|
||||
DEF_GLOBAL(port_80, "80");
|
||||
|
||||
|
|
|
@ -125,7 +125,7 @@ module Mongrel
|
|||
REQUEST_URI='REQUEST_URI'.freeze
|
||||
REQUEST_PATH='REQUEST_PATH'.freeze
|
||||
|
||||
MONGREL_VERSION="0.3.19".freeze
|
||||
MONGREL_VERSION="0.3.20".freeze
|
||||
|
||||
MONGREL_TMP_BASE="mongrel".freeze
|
||||
|
||||
|
@ -336,15 +336,18 @@ module Mongrel
|
|||
# semantics for Hash (where doing an insert replaces) is not there.
|
||||
class HeaderOut
|
||||
attr_reader :out
|
||||
attr_accessor :allowed_duplicates
|
||||
|
||||
def initialize(out)
|
||||
@sent = {}
|
||||
@allowed_duplicates = {"Set-Cookie" => true, "Set-Cookie2" => true,
|
||||
"Warning" => true, "WWW-Authenticate" => true}
|
||||
@out = out
|
||||
end
|
||||
|
||||
# Simply writes "#{key}: #{value}" to an output buffer.
|
||||
def[]=(key,value)
|
||||
if not @sent.has_key?(key)
|
||||
if not @sent.has_key?(key) or @allowed_duplicates.has_key?(key)
|
||||
@sent[key] = true
|
||||
@out.write(Const::HEADER_FORMAT % [key, value])
|
||||
end
|
||||
|
|
|
@ -50,6 +50,24 @@ class ResponseTest < Test::Unit::TestCase
|
|||
assert_equal io.length, 95, "too much output"
|
||||
end
|
||||
|
||||
|
||||
def test_response_some_duplicates_allowed
|
||||
allowed_duplicates = ["Set-Cookie", "Set-Cookie2", "Warning", "WWW-Authenticate"]
|
||||
io = StringIO.new
|
||||
resp = HttpResponse.new(io)
|
||||
resp.start do |head,out|
|
||||
allowed_duplicates.each do |dup|
|
||||
10.times do |i|
|
||||
head[dup] = i
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
resp.finished
|
||||
|
||||
assert_equal io.length, 734, "wrong amount of output"
|
||||
end
|
||||
|
||||
def test_response_404
|
||||
io = StringIO.new
|
||||
|
||||
|
|
Loading…
Reference in a new issue