Open pcfreak30 opened 9 years ago
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.
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
Please add an acceptInvalidCookies option. An example of a site that is requiring this is http://www.academicjournals.org.
Thanks