request / request-promise

The simplified HTTP request client 'request' with Promise support. Powered by Bluebird.
ISC License
4.77k stars 297 forks source link

Correction in the documentation for simple true flag on which ones reject and which ones resolve. #324

Closed rook2pawn closed 5 years ago

rook2pawn commented 5 years ago

It looks like there is an inaccuracy

In the README it says

Plus some additional options: simple = true which is a boolean to set whether status codes other than 2xx should also reject the promise

However, a simple test proves that a 301 with a Location redirect will not reject the promise.

Can we say

simple = true which is a boolean to set whether status codes other than 2xx or 3xx should also reject the promise

?

    const http = require("http");
    const rp = require("request-promise-native");
    const server = http.createServer((req, res) => {
    res.writeHead(301, { Location: "https://google.com" });
    res.end();
    });
    server.listen(5150);
    rp({ uri: "http://localhost:5150", simple: true })
    .then(function(htmlString) {
        console.log("Response:", htmlString);
    })
    .catch(function(err) {
        console.log("Caught e:", err);
    });