Skip to content

Commit

Permalink
remove @host ivar
Browse files Browse the repository at this point in the history
  • Loading branch information
tenderlove committed Aug 6, 2015
1 parent aad33d5 commit 3d32a50
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ def handle_unverified_request
request.session = NullSessionHash.new(request.env)
request.env['action_dispatch.request.flash_hash'] = nil
request.env['rack.session.options'] = { skip: true }
request.env['action_dispatch.cookies'] = NullCookieJar.build(request)
request.env['action_dispatch.cookies'] = NullCookieJar.build(request, {})
end

protected
Expand All @@ -160,12 +160,6 @@ def exists?
end

class NullCookieJar < ActionDispatch::Cookies::CookieJar #:nodoc:
def self.build(request)
host = request.host

new(host, request)
end

def write(*)
# nothing
end
Expand Down
10 changes: 4 additions & 6 deletions actionpack/lib/action_dispatch/middleware/cookies.rb
Original file line number Diff line number Diff line change
Expand Up @@ -259,16 +259,14 @@ class CookieJar #:nodoc:
DOMAIN_REGEXP = /[^.]*\.([^.]*|..\...|...\...)$/

def self.build(req, cookies)
host = req.host
new(host, req).tap do |hash|
new(req).tap do |hash|
hash.update(cookies)
end
end

def initialize(host = nil, request)
def initialize(request)
@set_cookies = {}
@delete_cookies = {}
@host = host
@request = request
@cookies = {}
@committed = false
Expand Down Expand Up @@ -318,12 +316,12 @@ def handle_options(options) #:nodoc:

# if host is not ip and matches domain regexp
# (ip confirms to domain regexp so we explicitly check for ip)
options[:domain] = if (@host !~ /^[\d.]+$/) && (@host =~ domain_regexp)
options[:domain] = if (@request.host !~ /^[\d.]+$/) && (@request.host =~ domain_regexp)
".#{$&}"
end
elsif options[:domain].is_a? Array
# if host matches one of the supplied domains without a dot in front of it
options[:domain] = options[:domain].find {|domain| @host.include? domain.sub(/^\./, '') }
options[:domain] = options[:domain].find {|domain| @request.host.include? domain.sub(/^\./, '') }
end
end

Expand Down

0 comments on commit 3d32a50

Please sign in to comment.