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

Use tough-cookie CookieJar sync API #767

Merged
merged 2 commits into from
Jan 14, 2014

Conversation

stash
Copy link
Contributor

@stash stash commented Jan 13, 2014

This restores backwards-compatibility with jar parameters (i.e. jar.setCookie takes two parameters and is guaranteed synchronous).

The async API for tough-cookie can't be used without major changes to request itself, so I've left that for another day.

@stash
Copy link
Contributor Author

stash commented Jan 13, 2014

cc @lalitkapoor

try {
targetCookieJar.setCookie(cookie, self.uri.href);
} catch (e) {
self.emit('cookieError', e);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not sure if this is better than the console.warn - let me know.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

when/where would this error?

you might want to just emit an error normally.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The real-world failures should be quite limited; egregious formatting errors for the cookie or the domain. I'll change this to .emit('error')

@stash stash mentioned this pull request Jan 13, 2014
@lalitkapoor
Copy link
Member

@stash this definitely makes it more friendly. I tried to build a cleaner interface for using tough-cookie here: https://github.com/lalitkapoor/request-cookies (needs to be refactored to use sync api now). What are your thoughts?

On a side note I have some ideas for implementing sync differently, but I'll post that on goinstant/node-cookie instead of here.

@stash
Copy link
Contributor Author

stash commented Jan 14, 2014

@lalitkapoor definitely take what I've got in this branch's lib/cookies.js - plus I like the flexible API you made.

@stash
Copy link
Contributor Author

stash commented Jan 14, 2014

@mikeal ok, changed that line to emit('error') instead of 'cookieError'

mikeal added a commit that referenced this pull request Jan 14, 2014
Use tough-cookie CookieJar sync API
@mikeal mikeal merged commit b1224af into request:master Jan 14, 2014
@stash stash deleted the stash/sync-cookie-api branch January 14, 2014 19:04
nylen pushed a commit to nylen/request that referenced this pull request Oct 17, 2014
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

Successfully merging this pull request may close these issues.

None yet

3 participants