配置httpbuilder ng的http客户端不跟随302重定向
Configure the http client of httpbuilder ng to not follow 302 redirects
我尝试使用 Groovy 和 http-builder-ng
为我的 Web 应用程序编写一些回归测试。
要检查每个请求的所有 headers 我想关闭
自动重定向。要用 http-builder
做到这一点,有 BasicHttpParams
,但我认为 BasicHttpParams
不适用于 http-builder-ng
。
还有其他关闭自动重定向的方法吗?
我之前没有使用 http-builder-ng
,但是从文档中我没有看到直接配置它的方法。但是您在客户端实现中使用了一些变体,默认为 core
、apache
或 okhttp
。我想您需要配置您正在使用的底层客户端库,以不使用 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 }
}
我尝试使用 Groovy 和 http-builder-ng
为我的 Web 应用程序编写一些回归测试。
要检查每个请求的所有 headers 我想关闭
自动重定向。要用 http-builder
做到这一点,有 BasicHttpParams
,但我认为 BasicHttpParams
不适用于 http-builder-ng
。
还有其他关闭自动重定向的方法吗?
我之前没有使用 http-builder-ng
,但是从文档中我没有看到直接配置它的方法。但是您在客户端实现中使用了一些变体,默认为 core
、apache
或 okhttp
。我想您需要配置您正在使用的底层客户端库,以不使用 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 }
}