Set the originAttributes column when inserting a record

This commit is contained in:
Akinori MUSHA 2016-12-08 23:42:40 +09:00
parent 930d8242cf
commit 40d988ab92

View file

@ -22,14 +22,11 @@ class HTTP::CookieJar
ALL_COLUMNS = %w[ ALL_COLUMNS = %w[
baseDomain baseDomain
appId inBrowserElement originAttributes
name value name value
host path host path
expiry creationTime lastAccessed expiry creationTime lastAccessed
isSecure isHttpOnly isSecure isHttpOnly
]
UK_COLUMNS = %w[
name host path
appId inBrowserElement appId inBrowserElement
] ]
@ -95,6 +92,11 @@ class HTTP::CookieJar
def initialize(options = nil) def initialize(options = nil)
super super
@origin_attributes = URI.encode_www_form({}.tap { |params|
params['appId'] = @app_id if @app_id.nonzero?
params['inBrowserElement'] = 1 if @in_browser_element
})
@filename = options[:filename] or raise ArgumentError, ':filename option is missing' @filename = options[:filename] or raise ArgumentError, ':filename option is missing'
@sjar = HTTP::CookieJar::HashStore.new @sjar = HTTP::CookieJar::HashStore.new
@ -360,8 +362,7 @@ class HTTP::CookieJar
def db_add(cookie) def db_add(cookie)
@stmt[:add].execute({ @stmt[:add].execute({
:baseDomain => cookie.domain_name.domain || cookie.domain, :baseDomain => cookie.domain_name.domain || cookie.domain,
:appId => @app_id, :originAttributes => @origin_attributes,
:inBrowserElement => @in_browser_element ? 1 : 0,
:name => cookie.name, :value => cookie.value, :name => cookie.name, :value => cookie.value,
:host => cookie.dot_domain, :host => cookie.dot_domain,
:path => cookie.path, :path => cookie.path,
@ -370,6 +371,8 @@ class HTTP::CookieJar
:lastAccessed => cookie.accessed_at.to_i, :lastAccessed => cookie.accessed_at.to_i,
:isSecure => cookie.secure? ? 1 : 0, :isSecure => cookie.secure? ? 1 : 0,
:isHttpOnly => cookie.httponly? ? 1 : 0, :isHttpOnly => cookie.httponly? ? 1 : 0,
:appId => @app_id,
:inBrowserElement => @in_browser_element ? 1 : 0,
}) })
cleanup if (@gc_index += 1) >= @gc_threshold cleanup if (@gc_index += 1) >= @gc_threshold