Commit c5efc98b authored by analog-nico's avatar analog-nico
Browse files

Fix for init calls after redirects

parent 1c26c555
Loading
Loading
Loading
Loading
+8 −16
Original line number Diff line number Diff line
@@ -51,18 +51,17 @@ request.Request.prototype.init = function (options) {

    var self = this;

    self._rp_promise = new Bluebird(function (resolve, reject) {
    // Init may be called again - currently in case of redirects
    if (_.isPlainObject(options) && self._callback === undefined && self._rp_promise === undefined) {

        self._rp_promise = new Bluebird(function (resolve, reject) {
            self._rp_resolve = resolve;
            self._rp_reject = reject;

        });

        self._rp_callbackOrig = self.callback;
        self.callback = ownCallback;

    if (_.isPlainObject(options)) {

        if (_.isString(options.method)) {
            options.method = options.method.toUpperCase();
        }
@@ -71,13 +70,6 @@ request.Request.prototype.init = function (options) {
        self._rp_options.simple = options.simple === false ? false : true;
        self._rp_options.resolveWithFullResponse = options.resolveWithFullResponse === true ? true : false;

    } else {

        self._rp_options = {
            simple: true,
            resolveWithFullResponse: false
        };

    }

    return originalInit.apply(self, arguments);