Nothing is fundamentally wrong with this API,
but I admit I don't see what the rationals for
this API are. Having a Storage with opaque Data
forces Jar to serialize Cookies and the filter
functions f to decode this serialization before
doing actual work. Is it about squeezing the
booleans HostOnly, Secure and HttpOnly into a
bitfield and compressing Value to minimize the
memory footprint of an in-memory Storage?
Or is it just a way to avoid an additional type
StoredCookie which would share several fields with
http.Cookie?
Having LastAccess exposed in Entry and managed by
Storage is nice, but only if LastAccess is used
somewhere: The only two task where LastAccess
is ever used is a) display in a GUI and b) during
compactification of the jar when LastAccess helps
to decide which cookies to drop from the jar.
Such functions should be part of the API, at least
if we are heading for a general "suits-everything"
cookie jar.
Just to be sure: The general design is fixed to
"Jar delegates all cookie storage to an interface
type Storage"? Or are other designs like "Package
cookiejar provides an efficent in-memory cookie
jar as well as functions to build specialized
cookie jars." or "The way chromium/firefox does."
still discussed?
https://codereview.appspot.com/6849092/diff/10001/src/pkg/net/http/cookiejar/jar.goFile src/pkg/net/http/cookiejar/jar.go (right):
https://codereview.appspot.com/6849092/diff/10001/src/pkg/net/http/cookiejar/jar.go#newcode44src/pkg/net/http/cookiejar/jar.go:44: // Jar implements the
http.CookieJar interface from the net/http package.
Russ's Options could be used for stuff like allowing
host cookies on IP addresses and safeguarding against
excessive long Value.
https://codereview.appspot.com/6849092/diff/10001/src/pkg/net/http/cookiejar/jar.go#newcode56src/pkg/net/http/cookiejar/jar.go:56: // TODO: how do we reject HttpOnly
cookies? Do we post-process the return
On 2012/11/25 15:58:51, rsc wrote:
I don't understand this TODO. Both the Cookies and SetCookies methods
have a URL
so it seems like they can tell HTTP from HTTPS.
It is (I assume) about telling HTTP(S) from FTP
and other protocols, not about telling HTTP from
HTTPS (which is controlled by Secure field).
https://codereview.appspot.com/6849092/diff/10001/src/pkg/net/http/cookiejar/jar.go#newcode56src/pkg/net/http/cookiejar/jar.go:56: // TODO: how do we reject HttpOnly
cookies? Do we post-process the return
Allowing an ftp server to set a cookie which gets sent
to a HTTP request (and the other way around) might be
allowed in theory, but most probably this is a bad
idea. I would be strict (and safe): "Jar will neither
accept cookies from, nor send cookies to any URL which
is neither HTTP nor HTTPS."
https://codereview.appspot.com/6849092/diff/10001/src/pkg/net/http/cookiejar/storage.goFile src/pkg/net/http/cookiejar/storage.go (right):
https://codereview.appspot.com/6849092/diff/10001/src/pkg/net/http/cookiejar/storage.go#newcode66src/pkg/net/http/cookiejar/storage.go:66: Creation time.Time
Why is Creation treated special here? Created is set once
like Name or Path and not used for retrieval (it is not
even used for cleanup or shrinking the jar). Just because
LastAccess is handled special?
https://codereview.appspot.com/6849092/