即使添加 followAllRedirects
也只会将 response.statusCode
从 302
更改为 200
,但 body
保留前一个响应的内容,并且响应
的所有其他属性都反射(reflect)旧的属性。
注意:我正在使用 grunt 进行测试。
有什么原因导致不遵循重定向吗?
最佳答案
它写在文档 https://github.com/mikeal/request#requestjar 中:
Cookies are disabled by default (else, they would be used in subsequent requests). To enable cookies, set jar to true (either in defaults or options).
var request = request.defaults({jar: true})
request('http://www.google.com', function () {
request('http://images.google.com')
})
关于node.js - 带有请求的 jasmine-node - 测试重定向的端点不遵循重定向,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23721708/