【问题标题】:jasmine-node with request - testing endpoints that redirect don't follow redirects带有请求的 jasmine-node - 测试重定向的端点不遵循重定向
【发布时间】:2014-05-18 12:08:15
【问题描述】:

即使添加followAllRedirects 仅将response.statusCode302 更改为200,但body 仍然是先前响应的内容,response 的所有其他属性都反映了旧的。

注意:我正在使用 grunt 进行这些测试。

不遵循重定向的任何原因?

【问题讨论】:

    标签: node.js redirect jasmine-node node-request


    【解决方案1】:

    它写在文档https://github.com/mikeal/request#requestjar:

    默认情况下禁用 Cookie(否则,它们将用于 后续请求)。要启用 cookie,请将 jar 设置为 true(在 默认值或选项)。

    var request = request.defaults({jar: true})
    request('http://www.google.com', function () {
      request('http://images.google.com')
    })
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2012-07-27
      • 2019-04-09
      • 2013-02-12
      • 2020-04-17
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-08-11
      相关资源
      最近更新 更多