如何设置节点请求不遵循重定向

时间:2018-03-27 10:30:59

标签: node.js node-request

我已阅读document
followRedirect

- follow HTTP 3xx responses as redirects (default: true). This 
property can also be implemented as function which gets response object as a 
single argument and should return true if redirects should continue or false 
otherwise.

但是设置followRedirect

let options = {
     url: url,
     method: 'GET',
     headers: {
            'user-agent': 'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/61.0.3163.100 Safari/537.36',
     },
     followRedirect: function (resp) {
         return false;
     },
};

设置不起作用。当我得到200时,response.statusCode应该是307。

0 个答案:

没有答案