【问题标题】:Configure the http client of httpbuilder ng to not follow 302 redirects配置httpbuilder ng的http客户端不遵循302重定向
【发布时间】:2018-05-11 22:17:32
【问题描述】:

我尝试使用 Groovy 和 http-builder-ng 为我的 Web 应用程序编写一些回归测试。
要检查每个请求的所有标头,我想关闭 自动重定向。要做到这一点http-builderBasicHttpParams,但我认为BasicHttpParams 不适用于http-builder-ng
还有其他方法可以关闭自动重定向吗?

【问题讨论】:

    标签: http redirect groovy httpbuilder-ng


    【解决方案1】:

    我之前没有使用过http-builder-ng,但是从文档中我看不到直接配置它的方法。但是您在客户端实现中使用了一些变体,默认情况下为coreapacheokhttp。我想您需要配置您正在使用的底层客户端库,以不使用clientCustomizer 进行重定向,如https://http-builder-ng.github.io/http-builder-ng/asciidoc/html5/#_client 所述。

    E. G。使用core 变体:

    http = configure {
        request.uri = 'test.com'
        client.clientCustomizer { it.followRedirects = false }
    }
    

    【讨论】:

      猜你喜欢
      • 2019-05-10
      • 2016-12-01
      • 2013-08-15
      • 1970-01-01
      • 2012-07-27
      • 2014-03-13
      • 2013-12-15
      • 1970-01-01
      • 2013-09-11
      相关资源
      最近更新 更多