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

Disallowed streaming

parent 3b489f72
Loading
Loading
Loading
Loading
+8 −0
Original line number Original line Diff line number Diff line
@@ -142,4 +142,12 @@ request.Request.prototype.promise = function RP$promise() {
};
};




function RP$noStreaming() {
    throw new Error('Request-Promise does not support streaming the response. Please use the original Request library for that.');
}

request.Request.prototype.pipe = RP$noStreaming;
request.Request.prototype.pipeDest = RP$noStreaming;


module.exports = request;
module.exports = request;
+16 −17
Original line number Original line Diff line number Diff line
@@ -894,23 +894,6 @@ describe('Request-Promise', function () {
                });
                });
        });
        });


        it('for piping data while also the promise is used', function (done) {

            var req = rp('http://localhost:4000/200');

            var _data;
            req.pipe(es.wait(function (err, data) {
                    _data = data.toString();
                }));

            req.then(function (body) {
                    expect(body).to.eql('GET /200');
                    expect(_data).to.eql('GET /200');
                    done();
                });

        });

        it('for requests with a redirect', function () {
        it('for requests with a redirect', function () {


            return rp('http://localhost:4000/302')
            return rp('http://localhost:4000/302')
@@ -970,6 +953,22 @@ describe('Request-Promise', function () {


        });
        });


        it('by not allowing the use of .pipe(...)', function () {

            expect(function () {
                rp('http://localhost:4000/200').pipe();
            }).to.throw();

        });

        it('by not allowing the use of .pipeDest(...)', function () {

            expect(function () {
                rp('http://localhost:4000/200').pipeDest();
            }).to.throw();

        });

    });
    });


    describe('should still allow to require Request independently', function (done) {
    describe('should still allow to require Request independently', function (done) {