mirror of
https://gitea.invidious.io/iv-org/invidious-copy-2022-03-16.git
synced 2024-08-15 00:53:18 +00:00
Add fix for HTTP::Cookies
This commit is contained in:
parent
d8372aa83e
commit
6581f96b70
2 changed files with 29 additions and 0 deletions
28
src/cookie_fix.cr
Normal file
28
src/cookie_fix.cr
Normal file
|
@ -0,0 +1,28 @@
|
|||
module HTTP
|
||||
class Cookie
|
||||
module Parser
|
||||
SetCookieStringFix = /^#{Regex::CookiePair}(?:;\s*#{Regex::CookieAV})*$/
|
||||
|
||||
def parse_set_cookie(header)
|
||||
match = header.match(SetCookieStringFix)
|
||||
return unless match
|
||||
|
||||
expires = if max_age = match["max_age"]?
|
||||
Time.now + max_age.to_i.seconds
|
||||
else
|
||||
parse_time(match["expires"]?)
|
||||
end
|
||||
|
||||
Cookie.new(
|
||||
match["name"], match["value"],
|
||||
path: match["path"]? || "/",
|
||||
expires: expires,
|
||||
domain: match["domain"]?,
|
||||
secure: match["secure"]? != nil,
|
||||
http_only: match["http_only"]? != nil,
|
||||
extension: match["extension"]?
|
||||
)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -20,6 +20,7 @@ require "pg"
|
|||
require "xml"
|
||||
require "yaml"
|
||||
require "./helpers"
|
||||
require "./cookie_fix"
|
||||
|
||||
CONFIG = Config.from_yaml(File.read("config/config.yml"))
|
||||
|
||||
|
|
Loading…
Reference in a new issue