Configure the http client of httpbuilder ng to not follow 302 redirects

576 Views Asked by At

I try to write some regression tests for my web application with Groovy and http-builder-ng.
To check all the headers for every request I would like to turn off the auto redirection. To do this with http-builder there are BasicHttpParams, but I think BasicHttpParams are not working with http-builder-ng.
Is there another way to turn off auto redirection?

1

There are 1 best solutions below

0
Vampire On BEST ANSWER

I didn't use http-builder-ng before, but from the docs I don't see a way to configure this directly. But you use some variant with client implementation, by default core, apache or okhttp. I guess you need to configure the underlying client library you are using to not follow redirects using clientCustomizer as described at https://http-builder-ng.github.io/http-builder-ng/asciidoc/html5/#_client.

E. g. with the core variant:

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