aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib/action_dispatch
diff options
context:
space:
mode:
authorJeremy Daer <jeremydaer@gmail.com>2015-10-03 22:05:01 -0700
committerJeremy Daer <jeremydaer@gmail.com>2015-10-03 22:05:01 -0700
commit67597e1719ec6af7e22964603cc77aa5b085a864 (patch)
treea82b9781bd1c2efb85252e376fa9d27fc94d1f29 /actionpack/lib/action_dispatch
parent24b1850130c68fe70b912277527e9c139ccc6742 (diff)
parent2356403330f2fa60045c858434cad550f6b3ee46 (diff)
downloadrails-67597e1719ec6af7e22964603cc77aa5b085a864.tar.gz
rails-67597e1719ec6af7e22964603cc77aa5b085a864.tar.bz2
rails-67597e1719ec6af7e22964603cc77aa5b085a864.zip
Merge pull request #21861 from jeremy/rack-add-header
Introduce `Headers#add`. Move `Response#add_header` upstream.
Diffstat (limited to 'actionpack/lib/action_dispatch')
-rw-r--r--actionpack/lib/action_dispatch/http/cache.rb4
-rw-r--r--actionpack/lib/action_dispatch/http/headers.rb5
-rw-r--r--actionpack/lib/action_dispatch/http/response.rb22
3 files changed, 8 insertions, 23 deletions
diff --git a/actionpack/lib/action_dispatch/http/cache.rb b/actionpack/lib/action_dispatch/http/cache.rb
index 1d0a6b6eb3..6b25ee9a70 100644
--- a/actionpack/lib/action_dispatch/http/cache.rb
+++ b/actionpack/lib/action_dispatch/http/cache.rb
@@ -59,7 +59,7 @@ module ActionDispatch
end
def last_modified?
- have_header? LAST_MODIFIED
+ has_header? LAST_MODIFIED
end
def last_modified=(utc_time)
@@ -73,7 +73,7 @@ module ActionDispatch
end
def date?
- have_header? DATE
+ has_header? DATE
end
def date=(utc_time)
diff --git a/actionpack/lib/action_dispatch/http/headers.rb b/actionpack/lib/action_dispatch/http/headers.rb
index 9a3aaca3f0..12f81dc1a5 100644
--- a/actionpack/lib/action_dispatch/http/headers.rb
+++ b/actionpack/lib/action_dispatch/http/headers.rb
@@ -49,6 +49,11 @@ module ActionDispatch
@req.set_header env_name(key), value
end
+ # Add a value to a multivalued header like Vary or Accept-Encoding.
+ def add(key, value)
+ @req.add_header env_name(key), value
+ end
+
def key?(key)
@req.has_header? env_name(key)
end
diff --git a/actionpack/lib/action_dispatch/http/response.rb b/actionpack/lib/action_dispatch/http/response.rb
index f6f63f1f32..a27ff67114 100644
--- a/actionpack/lib/action_dispatch/http/response.rb
+++ b/actionpack/lib/action_dispatch/http/response.rb
@@ -156,31 +156,11 @@ module ActionDispatch # :nodoc:
yield self if block_given?
end
- def have_header?(key); headers.key? key; end
+ def has_header?(key); headers.key? key; end
def get_header(key); headers[key]; end
def set_header(key, v); headers[key] = v; end
def delete_header(key); headers.delete key; end
- # Add a header that may have multiple values.
- #
- # Example:
- # response.add_header 'Vary', 'Accept'
- # response.add_header 'Vary', 'Accept-Encoding'
- # response.add_header 'Vary', 'Cookie'
- #
- # assert_equal 'Accept,Accept-Encoding,Cookie', response.get_header 'Vary'
- #
- # http://www.w3.org/Protocols/rfc2616/rfc2616-sec4.html#sec4.2
- def add_header(key, v)
- if v.nil?
- get_header key
- elsif have_header? key
- set_header key, "#{get_header key},#{v}"
- else
- set_header key, v
- end
- end
-
def await_commit
synchronize do
@cv.wait_until { @committed }