You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I ran into this when replacing some cURL-ing that had been done with the justification that it was easier to use cURL to maintain the session than using http.rb or other ruby http libraries. Here's the function I used:
Chainable#cookies now accepts any enumerable of HTTP::Cookie objects in addition to a Hash, so passing a cookie jar from a previous response works directly:
This was part of a broader cookie API refactor (0dd249f) that removed cookie management from Options and simplified Chainable#cookies to set the Cookie header directly from a Hash or Array<HTTP::Cookie>. Since HTTP::CookieJar is Enumerable and yields HTTP::Cookie objects, it should work transparently.
Additionally, cookie jar management during redirects is now handled automatically by the Session (008c181), so manual cookie passing between redirect steps is no longer necessary.
If you encounter any issues with the new cookie API, please reopen this issue or file a new one.
Activity
tarcieri commentedon Nov 29, 2018
Reusing a
HTTP::CookieJar(automatically) between requests was something I had originally suggested in the form of anHTTP::Sessiontype: #306It looks like you're right though,
HTTP::Options#cookiesdoes not accept anHTTP::CookieJaras an argument, and probably should.odinhb commentedon Sep 25, 2020
I ran into this when replacing some cURL-ing that had been done with the justification that it was easier to use cURL to maintain the session than using http.rb or other ruby http libraries. Here's the function I used:
Allowing you to
HoneyryderChuck commentedon Sep 25, 2020
@odinhb there's at least 1 http ruby library supporting it
tarcieri commentedon Sep 25, 2020
We just landed #613 which adds support for it, but it isn't released
sferik commentedon Mar 12, 2026
Chainable#cookiesnow accepts any enumerable ofHTTP::Cookieobjects in addition to aHash, so passing a cookie jar from a previous response works directly:This was part of a broader cookie API refactor (0dd249f) that removed cookie management from
Optionsand simplifiedChainable#cookiesto set theCookieheader directly from aHashorArray<HTTP::Cookie>. SinceHTTP::CookieJarisEnumerableand yieldsHTTP::Cookieobjects, it should work transparently.Additionally, cookie jar management during redirects is now handled automatically by the
Session(008c181), so manual cookie passing between redirect steps is no longer necessary.If you encounter any issues with the new cookie API, please reopen this issue or file a new one.