# Check First of Three Redirects on Gatling Test

**URL:** https://community.gatling.io/t/check-first-of-three-redirects-on-gatling-test/5479
**Category:** Gatling (Open-Source)
**Created:** [February 6, 2020, 3:30pm UTC](https://community.gatling.io/t/check-first-of-three-redirects-on-gatling-test/5479 "2020-02-06T15:30:30Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![Lucas\_Gajewski](https://avatars.discourse-cdn.com/v4/letter/l/e99b99/32.png) [@Lucas\_Gajewski](https://community.gatling.io/u/Lucas_Gajewski)
#### Post date: [February 6, 2020, 3:30pm UTC](https://community.gatling.io/t/check-first-of-three-redirects-on-gatling-test/5479/1 "2020-02-06T15:30:30Z")

</div>

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!

---

<div class="post-metadata">

### Author: ![Tenu\_Tensing](https://avatars.discourse-cdn.com/v4/letter/t/9d8465/32.png) [@Tenu\_Tensing](https://community.gatling.io/u/Tenu_Tensing)
#### Post date: [February 7, 2020, 8:06am UTC](https://community.gatling.io/t/check-first-of-three-redirects-on-gatling-test/5479/2 "2020-02-07T08:06:51Z")

</div>

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.

 ![REDIRECT.PNG](https://europe1.discourse-cdn.com/flex013/uploads/gatling2/original/1X/5ace15eaf884b18e6ceaee11a388113ab919def5.png)

Regards,  
Tenu

---

<div class="post-metadata">

### Author: ![Lucas\_Gajewski](https://avatars.discourse-cdn.com/v4/letter/l/e99b99/32.png) [@Lucas\_Gajewski](https://community.gatling.io/u/Lucas_Gajewski)
#### Post date: [February 13, 2020, 5:21pm UTC](https://community.gatling.io/t/check-first-of-three-redirects-on-gatling-test/5479/3 "2020-02-13T17:21:34Z")

</div>

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

 ![REDIRECT.PNG](https://europe1.discourse-cdn.com/flex013/uploads/gatling2/original/1X/5ace15eaf884b18e6ceaee11a388113ab919def5.png)

---

<div class="post-metadata">

### Author: ![slandelle](https://dub1.discourse-cdn.com/flex013/user_avatar/community.gatling.io/slandelle/32/4_2.png) [@slandelle](https://community.gatling.io/u/slandelle)
#### Post date: [February 13, 2020, 5:45pm UTC](https://community.gatling.io/t/check-first-of-three-redirects-on-gatling-test/5479/4 "2020-02-13T17:45:39Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![Lucas\_Gajewski](https://avatars.discourse-cdn.com/v4/letter/l/e99b99/32.png) [@Lucas\_Gajewski](https://community.gatling.io/u/Lucas_Gajewski)
#### Post date: [February 13, 2020, 10:34pm UTC](https://community.gatling.io/t/check-first-of-three-redirects-on-gatling-test/5479/5 "2020-02-13T22:34:04Z")

</div>

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

---

<div class="post-metadata">

### Author: ![slandelle](https://dub1.discourse-cdn.com/flex013/user_avatar/community.gatling.io/slandelle/32/4_2.png) [@slandelle](https://community.gatling.io/u/slandelle)
#### Post date: [February 14, 2020, 7:27am UTC](https://community.gatling.io/t/check-first-of-three-redirects-on-gatling-test/5479/6 "2020-02-14T07:27:27Z")

</div>

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?
