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

Accept invalid cookies #6

Open
pcfreak30 opened this issue Jul 3, 2015 · 2 comments
Open

Accept invalid cookies #6

pcfreak30 opened this issue Jul 3, 2015 · 2 comments

Comments

@pcfreak30
Copy link

Please add an acceptInvalidCookies option. An example of a site that is requiring this is http://www.academicjournals.org.

Thanks

@joepie91
Copy link
Owner

A temporary workaround for allowing this globally, is to monkeypatch the setCookie method in tough-cookie on an instantiated cookie jar. Something like this:

var jar = new ToughCookie();
var _setCookie = jar.setCookie;

jar.setCookie = function monkeypatchedSetCookie(cookieOrString, currentUrl, options, cb) {
    options.ignoreError = (options.ignoreError != null) ? options.ignoreError : true;
    _setCookie.call(jar, cookieOrString, currentUrl, options, cb);
}

(Note that this might fail if you omit the options argument and only specify a callback. I have not looked into how tough-cookie parses its arguments.)

I have not tested this workaround yet, though, and I'll need to think for a while about the most sensible way to integrate this option into bhttp. Let me know whether it works as intended.

@pcfreak30
Copy link
Author

        jar = new toughCookie.CookieJar(null, false);
        _setCookie = jar.setCookie
        jar.setCookie = (cookieOrString, currentUrl, options, cb) ->
            options.ignoreError = if options.ignoreError != null then options.ignoreError else true
            _setCookie.call(jar, cookieOrString, currentUrl, options, cb)

        @client = bhttp.session(
            agent: new (if @SSL then https else http).Agent(maxSockets: maxRequests)
            cookieJar: jar
        )

Still seems to crash

@joepie91 joepie91 added this to the feature-next milestone Aug 18, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants