Skip to content

Instantly share code, notes, and snippets.

@ook
Last active November 12, 2015 21:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ook/d054e3878376da4b40b6 to your computer and use it in GitHub Desktop.
Save ook/d054e3878376da4b40b6 to your computer and use it in GitHub Desktop.
HTTP has a #persistent mechanism, but cookies are not preserved between two calls
require 'http'
HTTP.persistent('https://www.service-client.veoliaeau.fr') do |http|
resp = http.get('/home/connexion-espace-client.html')
resp.to_s
puts resp.cookies.inspect
resp = http.get('/home/connexion-espace-client.html')
resp.to_s
puts resp.cookies.inspect
end
# Execution:
# #<HTTP::CookieJar:0x007fc99a8c2998 @store=#<HTTP::CookieJar::HashStore:0x007fc99abb51a0 @mon_owner=nil, @mon_count=0, @mon_mutex=#<Mutex:0x007fc99abb5150>, @logger=nil, @gc_threshold=150, @jar={"www.service-client.veoliaeau.fr"=>{"/"=>{"JSESSIONID"=>#<HTTP::Cookie:name="JSESSIONID", value="5007C757626571DAD21908CF0AC12B0C", domain="www.service-client.veoliaeau.fr", for_domain=false, path="/", secure=false, httponly=false, expires=nil, max_age=nil, created_at=2015-11-12 22:00:48 +0100, accessed_at=2015-11-12 22:00:48 +0100 origin=https://www.service-client.veoliaeau.fr/home/connexion-espace-client.html>}}}, @gc_index=1>>
#<HTTP::CookieJar:0x007fc99abde398 @store=#<HTTP::CookieJar::HashStore:0x007fc99abde2f8 @mon_owner=nil, @mon_count=0, @mon_mutex=#<Mutex:0x007fc99abde2a8>, @logger=nil, @gc_threshold=150, @jar={"www.service-client.veoliaeau.fr"=>{"/"=>{"JSESSIONID"=>#<HTTP::Cookie:name="JSESSIONID", value="4D35261DB40FB122BD83ECF898E2876E", domain="www.service-client.veoliaeau.fr", for_domain=false, path="/", secure=false, httponly=false, expires=nil, max_age=nil, created_at=2015-11-12 22:00:48 +0100, accessed_at=2015-11-12 22:00:48 +0100 origin=https://www.service-client.veoliaeau.fr/home/connexion-espace-client.html>}}}, @gc_index=1>>
# What I expect: the two JSESSIONID values should stay the same
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment