aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib
diff options
context:
space:
mode:
authorAaron Patterson <aaron.patterson@gmail.com>2015-08-27 11:12:03 -0700
committerAaron Patterson <aaron.patterson@gmail.com>2015-08-27 11:13:11 -0700
commit14af136371bbd9e14c58aaabe0ce73a515cd09a4 (patch)
tree7716fc9fc9c0cd9dde33786ce348f39dc65be214 /actionpack/lib
parent97d088ebf249c47a79aea419add1007fa24c1489 (diff)
downloadrails-14af136371bbd9e14c58aaabe0ce73a515cd09a4.tar.gz
rails-14af136371bbd9e14c58aaabe0ce73a515cd09a4.tar.bz2
rails-14af136371bbd9e14c58aaabe0ce73a515cd09a4.zip
implement the API required by the abstract Rack request.
Diffstat (limited to 'actionpack/lib')
-rw-r--r--actionpack/lib/action_dispatch/http/response.rb24
1 files changed, 8 insertions, 16 deletions
diff --git a/actionpack/lib/action_dispatch/http/response.rb b/actionpack/lib/action_dispatch/http/response.rb
index 0987efc474..16782a894e 100644
--- a/actionpack/lib/action_dispatch/http/response.rb
+++ b/actionpack/lib/action_dispatch/http/response.rb
@@ -150,6 +150,11 @@ module ActionDispatch # :nodoc:
yield self if block_given?
end
+ def have_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
+
def await_commit
synchronize do
@cv.wait_until { @committed }
@@ -256,22 +261,9 @@ module ActionDispatch # :nodoc:
parts
end
- def set_cookie(key, value)
- header[SET_COOKIE] = ::Rack::Utils.add_cookie_to_header(header[SET_COOKIE], key, value)
- end
-
- def delete_cookie(key, value={})
- header[SET_COOKIE] = ::Rack::Utils.add_remove_cookie_to_header(header[SET_COOKIE], key, value)
- end
-
# The location header we'll be responding with.
alias_method :redirect_url, :location
- # Sets the location header we'll be responding with.
- def location=(url)
- headers[LOCATION] = url
- end
-
def close
stream.close if stream.respond_to?(:close)
end
@@ -302,7 +294,7 @@ module ActionDispatch # :nodoc:
# assert_equal 'AuthorOfNewPage', r.cookies['author']
def cookies
cookies = {}
- if header = self[SET_COOKIE]
+ if header = get_header(SET_COOKIE)
header = header.split("\n") if header.respond_to?(:to_str)
header.each do |cookie|
if pair = cookie.split(';').first
@@ -338,14 +330,14 @@ module ActionDispatch # :nodoc:
end
def assign_default_content_type_and_charset!
- return if self[CONTENT_TYPE].present?
+ return if get_header(CONTENT_TYPE).present?
@content_type ||= Mime::HTML
type = @content_type.to_s.dup
type << "; charset=#{charset}" if append_charset?
- self[CONTENT_TYPE] = type
+ set_header CONTENT_TYPE, type
end
def append_charset?