Go: net/http/cookiejar: add a disk backed persistent CookieJar

Created on 31 Jan 2020  路  6Comments  路  Source: golang/go

hi mr, sorry for this silly issue, but can we have this feature in Go ?, i think as a battery-included language, we should have this feature mr.

nb : Python has this feature by the way, https://docs.python.org/3/library/http.cookiejar.html#http.cookiejar.FileCookieJar

NeedsInvestigation help wanted

Most helpful comment

There is a possibility, but it's not going to happen by just waiting for me to get around to it.

All 6 comments

CC @nigeltao

Quoting https://groups.google.com/d/msg/golang-nuts/7mf8z9bbEcY/bIjQBjePsVUJ from 2015:

Re persistent storage, there was a lot of discussion with [@vdobler] and I a couple of years ago about how to do a cookie jar with pluggable storage, but we never landed on a satisfactory design, let alone a perfect one, so what's in the standard library is not persistent.

but there is possibility right (?)

If you come to us with an existence proof of a good design for a
persistent cookie jar, I'm happy to look at it

There is a possibility, but it's not going to happen by just waiting for me to get around to it.

Hi, I'm the author of cookiestxt.
I think it's fair easy to port my code into cookiejar as TextMarshaler interface.

If you're talking about adding code to the Go standard library, the hard part isn't decoding/encoding the cookies text format. The hard part is designing an API that allows the persistent storage to be a text format, an SQLite database, other binary formats, etc. There may be thousands of cookies accumulated over months but, ideally, we'd still like better-than-O(N) lookup without first having to load all the cookies into memory. For persistent cookie storage, it should ideally also help handle the case where the Public Suffix List can change in between saving and loading the cookies.

See:

Was this page helpful?
0 / 5 - 0 ratings