Class: EventMachine::HttpClient::CookieJar

Inherits:
Object
  • Object
show all
Defined in:
lib/em-http/client.rb

Instance Method Summary collapse

Constructor Details

#initializeCookieJar

Returns a new instance of CookieJar



303
304
305
# File 'lib/em-http/client.rb', line 303

def initialize
  @jar = ::CookieJar::Jar.new
end

Instance Method Details

#get(uri) ⇒ Object



311
312
313
314
# File 'lib/em-http/client.rb', line 311

def get uri
  uri = URI.parse(uri) rescue nil
  uri ? @jar.get_cookies(uri) : []
end

#set(string, uri) ⇒ Object



307
308
309
# File 'lib/em-http/client.rb', line 307

def set string, uri
  @jar.set_cookie(uri, string) rescue nil # drop invalid cookies
end