aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib/action_controller
diff options
context:
space:
mode:
authorJoshua Peek <josh@joshpeek.com>2009-02-07 16:18:09 -0600
committerJoshua Peek <josh@joshpeek.com>2009-02-07 16:18:09 -0600
commit524d8edf68ab94315a128cbd7570d1cf4faf7d7a (patch)
tree9216f1a68194be1bc27a9e83de40205e1c419f4e /actionpack/lib/action_controller
parent0edb0a4facdf6de8d12a004b59232e1006b93cd9 (diff)
downloadrails-524d8edf68ab94315a128cbd7570d1cf4faf7d7a.tar.gz
rails-524d8edf68ab94315a128cbd7570d1cf4faf7d7a.tar.bz2
rails-524d8edf68ab94315a128cbd7570d1cf4faf7d7a.zip
Update bundled Rack for Ruby 1.9 spec changes
Diffstat (limited to 'actionpack/lib/action_controller')
-rw-r--r--actionpack/lib/action_controller/integration.rb2
-rw-r--r--actionpack/lib/action_controller/response.rb2
-rw-r--r--actionpack/lib/action_controller/session/abstract_store.rb9
-rw-r--r--actionpack/lib/action_controller/session/cookie_store.rb9
-rw-r--r--actionpack/lib/action_controller/streaming.rb2
-rw-r--r--actionpack/lib/action_controller/vendor/rack-1.0/rack/deflater.rb10
-rw-r--r--actionpack/lib/action_controller/vendor/rack-1.0/rack/handler/cgi.rb2
-rw-r--r--actionpack/lib/action_controller/vendor/rack-1.0/rack/handler/fastcgi.rb2
-rw-r--r--actionpack/lib/action_controller/vendor/rack-1.0/rack/handler/lsws.rb2
-rw-r--r--actionpack/lib/action_controller/vendor/rack-1.0/rack/handler/mongrel.rb2
-rw-r--r--actionpack/lib/action_controller/vendor/rack-1.0/rack/handler/scgi.rb2
-rw-r--r--actionpack/lib/action_controller/vendor/rack-1.0/rack/handler/webrick.rb4
-rw-r--r--actionpack/lib/action_controller/vendor/rack-1.0/rack/lint.rb17
-rw-r--r--actionpack/lib/action_controller/vendor/rack-1.0/rack/mock.rb4
-rw-r--r--actionpack/lib/action_controller/vendor/rack-1.0/rack/utils.rb9
-rw-r--r--actionpack/lib/action_controller/verification.rb2
16 files changed, 39 insertions, 41 deletions
diff --git a/actionpack/lib/action_controller/integration.rb b/actionpack/lib/action_controller/integration.rb
index a0e894108d..1c05ab0bf6 100644
--- a/actionpack/lib/action_controller/integration.rb
+++ b/actionpack/lib/action_controller/integration.rb
@@ -327,7 +327,7 @@ module ActionController
@headers = Rack::Utils::HeaderHash.new(headers)
- (@headers['Set-Cookie'] || []).each do |cookie|
+ (@headers['Set-Cookie'] || "").split("\n").each do |cookie|
name, value = cookie.match(/^([^=]*)=([^;]*);/)[1,2]
@cookies[name] = value
end
diff --git a/actionpack/lib/action_controller/response.rb b/actionpack/lib/action_controller/response.rb
index 6659907975..671699762d 100644
--- a/actionpack/lib/action_controller/response.rb
+++ b/actionpack/lib/action_controller/response.rb
@@ -41,7 +41,7 @@ module ActionController # :nodoc:
def initialize
@status = 200
- @header = DEFAULT_HEADERS.dup
+ @header = Rack::Utils::HeaderHash.new(DEFAULT_HEADERS)
@writer = lambda { |x| @body << x }
@block = nil
diff --git a/actionpack/lib/action_controller/session/abstract_store.rb b/actionpack/lib/action_controller/session/abstract_store.rb
index 69620cfd50..2f2a7410af 100644
--- a/actionpack/lib/action_controller/session/abstract_store.rb
+++ b/actionpack/lib/action_controller/session/abstract_store.rb
@@ -139,12 +139,9 @@ module ActionController
cookie << "; HttpOnly" if options[:httponly]
headers = response[1]
- case a = headers[SET_COOKIE]
- when Array
- a << cookie
- when String
- headers[SET_COOKIE] = [a, cookie]
- when nil
+ unless headers[SET_COOKIE].blank?
+ headers[SET_COOKIE] << "\n#{cookie}"
+ else
headers[SET_COOKIE] = cookie
end
end
diff --git a/actionpack/lib/action_controller/session/cookie_store.rb b/actionpack/lib/action_controller/session/cookie_store.rb
index 48db625f2b..a2543c1824 100644
--- a/actionpack/lib/action_controller/session/cookie_store.rb
+++ b/actionpack/lib/action_controller/session/cookie_store.rb
@@ -108,12 +108,9 @@ module ActionController
end
cookie = build_cookie(@key, cookie.merge(options))
- case headers[HTTP_SET_COOKIE]
- when Array
- headers[HTTP_SET_COOKIE] << cookie
- when String
- headers[HTTP_SET_COOKIE] = [headers[HTTP_SET_COOKIE], cookie]
- when nil
+ unless headers[HTTP_SET_COOKIE].blank?
+ headers[HTTP_SET_COOKIE] << "\n#{cookie}"
+ else
headers[HTTP_SET_COOKIE] = cookie
end
end
diff --git a/actionpack/lib/action_controller/streaming.rb b/actionpack/lib/action_controller/streaming.rb
index e1786913a7..b6a6a2e5db 100644
--- a/actionpack/lib/action_controller/streaming.rb
+++ b/actionpack/lib/action_controller/streaming.rb
@@ -152,7 +152,7 @@ module ActionController #:nodoc:
end
content_type = content_type.to_s.strip # fixes a problem with extra '\r' with some browsers
- headers.update(
+ headers.merge!(
'Content-Length' => options[:length],
'Content-Type' => content_type,
'Content-Disposition' => disposition,
diff --git a/actionpack/lib/action_controller/vendor/rack-1.0/rack/deflater.rb b/actionpack/lib/action_controller/vendor/rack-1.0/rack/deflater.rb
index 32f9a7ec29..3e66680092 100644
--- a/actionpack/lib/action_controller/vendor/rack-1.0/rack/deflater.rb
+++ b/actionpack/lib/action_controller/vendor/rack-1.0/rack/deflater.rb
@@ -36,17 +36,19 @@ module Rack
mtime = headers.key?("Last-Modified") ?
Time.httpdate(headers["Last-Modified"]) : Time.now
body = self.class.gzip(body, mtime)
- headers = headers.merge("Content-Encoding" => "gzip", "Content-Length" => body.length.to_s)
+ size = body.respond_to?(:bytesize) ? body.bytesize : body.size
+ headers = headers.merge("Content-Encoding" => "gzip", "Content-Length" => size.to_s)
[status, headers, [body]]
when "deflate"
body = self.class.deflate(body)
- headers = headers.merge("Content-Encoding" => "deflate", "Content-Length" => body.length.to_s)
+ size = body.respond_to?(:bytesize) ? body.bytesize : body.size
+ headers = headers.merge("Content-Encoding" => "deflate", "Content-Length" => size.to_s)
[status, headers, [body]]
when "identity"
[status, headers, body]
when nil
- message = ["An acceptable encoding for the requested resource #{request.fullpath} could not be found."]
- [406, {"Content-Type" => "text/plain", "Content-Length" => message[0].length.to_s}, message]
+ message = "An acceptable encoding for the requested resource #{request.fullpath} could not be found."
+ [406, {"Content-Type" => "text/plain", "Content-Length" => message.length.to_s}, [message]]
end
end
diff --git a/actionpack/lib/action_controller/vendor/rack-1.0/rack/handler/cgi.rb b/actionpack/lib/action_controller/vendor/rack-1.0/rack/handler/cgi.rb
index e8bf139da5..f2c976cf46 100644
--- a/actionpack/lib/action_controller/vendor/rack-1.0/rack/handler/cgi.rb
+++ b/actionpack/lib/action_controller/vendor/rack-1.0/rack/handler/cgi.rb
@@ -38,7 +38,7 @@ module Rack
def self.send_headers(status, headers)
STDOUT.print "Status: #{status}\r\n"
headers.each { |k, vs|
- vs.each { |v|
+ vs.split("\n").each { |v|
STDOUT.print "#{k}: #{v}\r\n"
}
}
diff --git a/actionpack/lib/action_controller/vendor/rack-1.0/rack/handler/fastcgi.rb b/actionpack/lib/action_controller/vendor/rack-1.0/rack/handler/fastcgi.rb
index 75b94e9943..f03e1615c9 100644
--- a/actionpack/lib/action_controller/vendor/rack-1.0/rack/handler/fastcgi.rb
+++ b/actionpack/lib/action_controller/vendor/rack-1.0/rack/handler/fastcgi.rb
@@ -67,7 +67,7 @@ module Rack
def self.send_headers(out, status, headers)
out.print "Status: #{status}\r\n"
headers.each { |k, vs|
- vs.each { |v|
+ vs.split("\n").each { |v|
out.print "#{k}: #{v}\r\n"
}
}
diff --git a/actionpack/lib/action_controller/vendor/rack-1.0/rack/handler/lsws.rb b/actionpack/lib/action_controller/vendor/rack-1.0/rack/handler/lsws.rb
index 265e67c10b..1f850fc77b 100644
--- a/actionpack/lib/action_controller/vendor/rack-1.0/rack/handler/lsws.rb
+++ b/actionpack/lib/action_controller/vendor/rack-1.0/rack/handler/lsws.rb
@@ -34,7 +34,7 @@ module Rack
def self.send_headers(status, headers)
print "Status: #{status}\r\n"
headers.each { |k, vs|
- vs.each { |v|
+ vs.split("\n").each { |v|
print "#{k}: #{v}\r\n"
}
}
diff --git a/actionpack/lib/action_controller/vendor/rack-1.0/rack/handler/mongrel.rb b/actionpack/lib/action_controller/vendor/rack-1.0/rack/handler/mongrel.rb
index cd906862a5..178a1a8fe4 100644
--- a/actionpack/lib/action_controller/vendor/rack-1.0/rack/handler/mongrel.rb
+++ b/actionpack/lib/action_controller/vendor/rack-1.0/rack/handler/mongrel.rb
@@ -63,7 +63,7 @@ module Rack
response.send_status(nil)
headers.each { |k, vs|
- vs.each { |v|
+ vs.split("\n").each { |v|
response.header[k] = v
}
}
diff --git a/actionpack/lib/action_controller/vendor/rack-1.0/rack/handler/scgi.rb b/actionpack/lib/action_controller/vendor/rack-1.0/rack/handler/scgi.rb
index 053944091b..fd18a8359b 100644
--- a/actionpack/lib/action_controller/vendor/rack-1.0/rack/handler/scgi.rb
+++ b/actionpack/lib/action_controller/vendor/rack-1.0/rack/handler/scgi.rb
@@ -44,7 +44,7 @@ module Rack
begin
socket.write("Status: #{status}\r\n")
headers.each do |k, vs|
- vs.each {|v| socket.write("#{k}: #{v}\r\n")}
+ vs.split("\n").each { |v| socket.write("#{k}: #{v}\r\n")}
end
socket.write("\r\n")
body.each {|s| socket.write(s)}
diff --git a/actionpack/lib/action_controller/vendor/rack-1.0/rack/handler/webrick.rb b/actionpack/lib/action_controller/vendor/rack-1.0/rack/handler/webrick.rb
index 604f48a288..40be79de13 100644
--- a/actionpack/lib/action_controller/vendor/rack-1.0/rack/handler/webrick.rb
+++ b/actionpack/lib/action_controller/vendor/rack-1.0/rack/handler/webrick.rb
@@ -42,9 +42,9 @@ module Rack
res.status = status.to_i
headers.each { |k, vs|
if k.downcase == "set-cookie"
- res.cookies.concat Array(vs)
+ res.cookies.concat vs.split("\n")
else
- vs.each { |v|
+ vs.split("\n").each { |v|
res[k] = v
}
end
diff --git a/actionpack/lib/action_controller/vendor/rack-1.0/rack/lint.rb b/actionpack/lib/action_controller/vendor/rack-1.0/rack/lint.rb
index c8c4f674e6..53e54955b7 100644
--- a/actionpack/lib/action_controller/vendor/rack-1.0/rack/lint.rb
+++ b/actionpack/lib/action_controller/vendor/rack-1.0/rack/lint.rb
@@ -338,16 +338,13 @@ module Rack
## but only contain keys that consist of
## letters, digits, <tt>_</tt> or <tt>-</tt> and start with a letter.
assert("invalid header name: #{key}") { key =~ /\A[a-zA-Z][a-zA-Z0-9_-]*\z/ }
- ##
- ## The values of the header must respond to #each.
- assert("header values must respond to #each, but the value of " +
- "'#{key}' doesn't (is #{value.class})") { value.respond_to? :each }
- value.each { |item|
- ## The values passed on #each must be Strings
- assert("header values must consist of Strings, but '#{key}' also contains a #{item.class}") {
- item.instance_of?(String)
- }
- ## and not contain characters below 037.
+
+ ## The values of the header must be Strings,
+ assert("a header value must be a String, but the value of " +
+ "'#{key}' is a #{value.class}") { value.kind_of? String }
+ ## consisting of lines (for multiple header values) seperated by "\n".
+ value.split("\n").each { |item|
+ ## The lines must not contain characters below 037.
assert("invalid header value #{key}: #{item.inspect}") {
item !~ /[\000-\037]/
}
diff --git a/actionpack/lib/action_controller/vendor/rack-1.0/rack/mock.rb b/actionpack/lib/action_controller/vendor/rack-1.0/rack/mock.rb
index b2951fb095..70852da3db 100644
--- a/actionpack/lib/action_controller/vendor/rack-1.0/rack/mock.rb
+++ b/actionpack/lib/action_controller/vendor/rack-1.0/rack/mock.rb
@@ -118,9 +118,7 @@ module Rack
@original_headers = headers
@headers = Rack::Utils::HeaderHash.new
headers.each { |field, values|
- values.each { |value|
- @headers[field] = value
- }
+ @headers[field] = values
@headers[field] = "" if values.empty?
}
diff --git a/actionpack/lib/action_controller/vendor/rack-1.0/rack/utils.rb b/actionpack/lib/action_controller/vendor/rack-1.0/rack/utils.rb
index 1bfe645176..5afeba7108 100644
--- a/actionpack/lib/action_controller/vendor/rack-1.0/rack/utils.rb
+++ b/actionpack/lib/action_controller/vendor/rack-1.0/rack/utils.rb
@@ -167,7 +167,14 @@ module Rack
end
def to_hash
- {}.replace(self)
+ inject({}) do |hash, (k,v)|
+ if v.respond_to? :to_ary
+ hash[k] = v.to_ary.join("\n")
+ else
+ hash[k] = v
+ end
+ hash
+ end
end
def [](k)
diff --git a/actionpack/lib/action_controller/verification.rb b/actionpack/lib/action_controller/verification.rb
index 7bf09ba6ea..c62b81b666 100644
--- a/actionpack/lib/action_controller/verification.rb
+++ b/actionpack/lib/action_controller/verification.rb
@@ -90,7 +90,7 @@ module ActionController #:nodoc:
def verify_action(options) #:nodoc:
if prereqs_invalid?(options)
flash.update(options[:add_flash]) if options[:add_flash]
- response.headers.update(options[:add_headers]) if options[:add_headers]
+ response.headers.merge!(options[:add_headers]) if options[:add_headers]
apply_remaining_actions(options) unless performed?
end
end