aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib/action_dispatch
diff options
context:
space:
mode:
Diffstat (limited to 'actionpack/lib/action_dispatch')
-rw-r--r--actionpack/lib/action_dispatch/http/rack_cache.rb9
-rw-r--r--actionpack/lib/action_dispatch/http/url.rb7
-rw-r--r--actionpack/lib/action_dispatch/middleware/cookies.rb14
-rw-r--r--actionpack/lib/action_dispatch/testing/performance_test.rb1
4 files changed, 12 insertions, 19 deletions
diff --git a/actionpack/lib/action_dispatch/http/rack_cache.rb b/actionpack/lib/action_dispatch/http/rack_cache.rb
index e5914abc81..b5c1435903 100644
--- a/actionpack/lib/action_dispatch/http/rack_cache.rb
+++ b/actionpack/lib/action_dispatch/http/rack_cache.rb
@@ -21,11 +21,6 @@ module ActionDispatch
@store.write(key, value)
end
- def purge(key)
- @store.delete(key)
- nil
- end
-
::Rack::Cache::MetaStore::RAILS = self
end
@@ -58,10 +53,6 @@ module ActionDispatch
[key, size]
end
- def purge(key)
- @store.delete(key)
- end
-
::Rack::Cache::EntityStore::RAILS = self
end
end
diff --git a/actionpack/lib/action_dispatch/http/url.rb b/actionpack/lib/action_dispatch/http/url.rb
index cfee95eb4b..4da82f958a 100644
--- a/actionpack/lib/action_dispatch/http/url.rb
+++ b/actionpack/lib/action_dispatch/http/url.rb
@@ -8,11 +8,6 @@ module ActionDispatch
protocol + host_with_port + fullpath
end
- # Returns 'https' if this is an SSL request and 'http' otherwise.
- def scheme
- ssl? ? 'https' : 'http'
- end
-
# Returns 'https://' if this is an SSL request and 'http://' otherwise.
def protocol
@protocol ||= ssl? ? 'https://' : 'http://'
@@ -99,4 +94,4 @@ module ActionDispatch
end
end
end
-end \ No newline at end of file
+end
diff --git a/actionpack/lib/action_dispatch/middleware/cookies.rb b/actionpack/lib/action_dispatch/middleware/cookies.rb
index 75c8cc3dd0..c4c2e1acd7 100644
--- a/actionpack/lib/action_dispatch/middleware/cookies.rb
+++ b/actionpack/lib/action_dispatch/middleware/cookies.rb
@@ -98,17 +98,19 @@ module ActionDispatch
def self.build(request)
secret = request.env[TOKEN_KEY]
host = request.host
+ secure = request.ssl?
- new(secret, host).tap do |hash|
+ new(secret, host, secure).tap do |hash|
hash.update(request.cookies)
end
end
- def initialize(secret = nil, host = nil)
+ def initialize(secret = nil, host = nil, secure = false)
@secret = secret
@set_cookies = {}
@delete_cookies = {}
@host = host
+ @secure = secure
super()
end
@@ -193,9 +195,15 @@ module ActionDispatch
end
def write(headers)
- @set_cookies.each { |k, v| ::Rack::Utils.set_cookie_header!(headers, k, v) }
+ @set_cookies.each { |k, v| ::Rack::Utils.set_cookie_header!(headers, k, v) if write_cookie?(v) }
@delete_cookies.each { |k, v| ::Rack::Utils.delete_cookie_header!(headers, k, v) }
end
+
+ private
+
+ def write_cookie?(cookie)
+ @secure || !cookie[:secure] || defined?(Rails.env) && Rails.env.development?
+ end
end
class PermanentCookieJar < CookieJar #:nodoc:
diff --git a/actionpack/lib/action_dispatch/testing/performance_test.rb b/actionpack/lib/action_dispatch/testing/performance_test.rb
index d6c98b4db7..e7aeb45fb3 100644
--- a/actionpack/lib/action_dispatch/testing/performance_test.rb
+++ b/actionpack/lib/action_dispatch/testing/performance_test.rb
@@ -1,5 +1,4 @@
require 'active_support/testing/performance'
-require 'active_support/testing/default'
begin
module ActionDispatch