Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

improve cookie caching code to not depend on local storage #105

Open
dougcole opened this issue May 7, 2015 · 2 comments
Open

improve cookie caching code to not depend on local storage #105

dougcole opened this issue May 7, 2015 · 2 comments

Comments

@dougcole
Copy link
Contributor

dougcole commented May 7, 2015

Right now the cookie caching code assumes the cookie storage is on a local disk. This works fine if you run all your rets interactions on a single machine or have some sort of shared filesystem, but it's not terribly flexible.

I'd prefer a caching mechanism that accepts an object that responds to read(name) and write(name) or something similar, then we can write plugins for this for nearly any storage system and simplify the process of running rets clients on multiple machines.

@hfaulds
Copy link
Contributor

hfaulds commented May 12, 2015

We use http-client which uses the http-cookie gem. I looked into what work would need to be done to use non-filesystem cookie stores with those gems:

http-cookie supports different cookie storing backends (their README at https://github.com/sparklemotion/http-cookie shows how to use alternate stores and they have a sqlite store implementation: https://github.com/sparklemotion/http-cookie/blob/master/lib/http/cookie_jar/mozilla_store.rb)

However HTTPClient's CookieManager code is set up to use the filesystem store (https://github.com/nahi/httpclient/blob/e11c7805c07d13989583aca91d9232231aafcd1e/lib/httpclient/cookie.rb#L22 would be unnecessary with the sqlite store, although I don't think it will necessarily break) and it doesn't expose the @jar instance var to set our own CookieJar implementation.

My take is that we'd need to write a custom CookieManager (which we can set on the HTTPClient object https://github.com/nahi/httpclient/blob/master/lib/httpclient.rb#L312) which instantiates a CookieJar with an arbitrary store (set by options).

There is another snag that http-cookie uses a java-esq system for loading cookiejar implementation and as far as I can tell one would probably have to either do some monkeypatch or instace var setting to get custom CookieJar implementations to load (https://github.com/sparklemotion/http-cookie/blob/master/lib/http/cookie_jar/abstract_store.rb#L18).

@hfaulds
Copy link
Contributor

hfaulds commented May 12, 2015

I was incorrect about that last paragraph. They handle passing in symbols or classes as the implementation (https://github.com/sparklemotion/http-cookie/blob/master/lib/http/cookie_jar.rb#L42-L47).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants