Class: CookiePersist

Inherits:
Object
  • Object
show all
Defined in:
lib/goshrine_bot/cookies.rb

Instance Method Summary collapse

Instance Method Details



31
32
33
34
35
# File 'lib/goshrine_bot/cookies.rb', line 31

def cookie_hash
  CookieHash.new.tap { |hsh|
    cookies.uniq.each { |c| hsh.add_cookies(c) }
  }
end

#cookiesObject



27
28
29
# File 'lib/goshrine_bot/cookies.rb', line 27

def cookies
  Thread.current[:cookies] ||= []
end

#request(client, head, body) ⇒ Object



37
38
39
40
# File 'lib/goshrine_bot/cookies.rb', line 37

def request(client, head, body)
  head['cookie'] = cookie_hash.to_cookie_string
  [head, body]
end

#response(resp) ⇒ Object



42
43
44
45
# File 'lib/goshrine_bot/cookies.rb', line 42

def response(resp)
  cookies << resp.response_header[EM::HttpClient::SET_COOKIE]
  resp
end