Check First of Three Redirects on Gatling Test

Hello,

I have an endpoint that, when called, redirects twice before reaching its final destination.
I want to check the first redirect and verify that it’s throwing the proper status code and headers before continuing on to the final destination.
Ex. Call → First Page – (redirect) → Second Page – (redirect) → Final Page
I want to check the headers and status code on the second page.

Is there an easy way to do this with Gatling?
I can’t use .disableFollowReedirects, and setting the .maxRedirects seems to just throw an error when it tries to move on, instead of limiting to one.

Any and all help would be appreciated!

Hi Lucas,

I faced a similar challenge and resolved it by fetching the redirected URLs from the previous response. We can check the headers and status code as well.

Code snippet is given below for your reference.
Hope this helps!

Note : I have used “.disableFollowRedirect” in my code. Since redirect is disabled, I have called each redirected URL separated in the scenario.

Regards,
Tenu

Thanks Tenu!
Pretty sure this is exactly what I need. Appreciate the rapid response.
Best,
Luke

No, this is a bad solution.
The correct way is to NOT disable redirects and use a currentLocation check to capture the data you want in the landing url.

Hi Slandelle,
Thank you for adding to the thread. Could you post an example of the code you’re referring to?
I need to be able to catch each response and verify data points (CORS headers, cookie attributes, etc.) as I go.
Thanks,
Luke

Gatling automatically deals with cookies and there’s no chance your actual client application can capture any data from the intermediate steps in the redirect chain. So what would you want to capture that you can’t find in the landing response?