# Dealing with redirects

**URL:** https://community.gatling.io/t/dealing-with-redirects/220
**Category:** Gatling (Open-Source)
**Created:** [January 9, 2013, 8:53pm UTC](https://community.gatling.io/t/dealing-with-redirects/220 "2013-01-09T20:53:32Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![ehsan\_rouhani](https://avatars.discourse-cdn.com/v4/letter/e/cab0a1/32.png) [@ehsan\_rouhani](https://community.gatling.io/u/ehsan_rouhani)
#### Post date: [January 9, 2013, 8:53pm UTC](https://community.gatling.io/t/dealing-with-redirects/220/1 "2013-01-09T20:53:32Z")

</div>

Hi,

I’m new to gatling so sorry if the question looks stupid. I’m sending a post including a user name and password for a login page.So the response for this request has nothing in the body and instead the page redirects two times and I see that in reports. The problem is how I can check stuff on the response’s body when I have redirects?!!

---

<div class="post-metadata">

### Author: ![Nicolas\_R](https://avatars.discourse-cdn.com/v4/letter/n/f14d63/32.png) [@Nicolas\_R](https://community.gatling.io/u/Nicolas_R)
#### Post date: [January 9, 2013, 8:58pm UTC](https://community.gatling.io/t/dealing-with-redirects/220/2 "2013-01-09T20:58:39Z")

</div>

Hi,

Well, the best solution I guess is not to follow the redirects. You can achieve this with the .disableFollowRedirect setting, see : [https://github.com/excilys/gatling/wiki/HTTP#wiki-follow-redirects](https://github.com/excilys/gatling/wiki/HTTP#wiki-follow-redirects)

Does this solve your problem ?

cheers  
Nicolas

---

<div class="post-metadata">

### Author: ![ehsan\_rouhani](https://avatars.discourse-cdn.com/v4/letter/e/cab0a1/32.png) [@ehsan\_rouhani](https://community.gatling.io/u/ehsan_rouhani)
#### Post date: [January 9, 2013, 9:05pm UTC](https://community.gatling.io/t/dealing-with-redirects/220/3 "2013-01-09T21:05:16Z")

</div>

So If I disable followredirect then how am I going to the new page?!

---

<div class="post-metadata">

### Author: ![Nicolas\_R](https://avatars.discourse-cdn.com/v4/letter/n/f14d63/32.png) [@Nicolas\_R](https://community.gatling.io/u/Nicolas_R)
#### Post date: [January 9, 2013, 9:15pm UTC](https://community.gatling.io/t/dealing-with-redirects/220/4 "2013-01-09T21:15:03Z")

</div>

You can do that like this :

.exec(  
http(“request1”)  
.get("/")  
.check(  
status.is(302),  
headers(“Location”).saveAs(“nextPageLocation”)  
)  
)  
.exec(  
http(“request2”)  
.get("${nextPageLocation}")  
.check(  
…  
)  
)

Does it work ?

---

<div class="post-metadata">

### Author: ![Nicolas\_R](https://avatars.discourse-cdn.com/v4/letter/n/f14d63/32.png) [@Nicolas\_R](https://community.gatling.io/u/Nicolas_R)
#### Post date: [January 9, 2013, 9:16pm UTC](https://community.gatling.io/t/dealing-with-redirects/220/5 "2013-01-09T21:16:14Z")

</div>

oops, it’s header() not headers(), cf : [https://github.com/excilys/gatling/wiki/Checks#wiki-header-value](https://github.com/excilys/gatling/wiki/Checks#wiki-header-value)

.exec(  
http(“request1”)  
.get("/")  
.check(  
status.is(302),  
header(“Location”).saveAs(“nextPageLocation”)  
)  
)  
.exec(  
http(“request2”)  
.get("${nextPageLocation}")  
.check(  
…  
)  
)

---

<div class="post-metadata">

### Author: ![Excilys](https://avatars.discourse-cdn.com/v4/letter/e/8797f3/32.png) [@Excilys](https://community.gatling.io/u/Excilys)
#### Post date: [January 9, 2013, 9:43pm UTC](https://community.gatling.io/t/dealing-with-redirects/220/6 "2013-01-09T21:43:51Z")

</div>

I’m not sure I correctly understand the question.

If you use a check on a redirected request, they’ll be applied to the landing page, not the redirected one.

---

<div class="post-metadata">

### Author: ![ehsan\_rouhani](https://avatars.discourse-cdn.com/v4/letter/e/cab0a1/32.png) [@ehsan\_rouhani](https://community.gatling.io/u/ehsan_rouhani)
#### Post date: [January 9, 2013, 9:56pm UTC](https://community.gatling.io/t/dealing-with-redirects/220/7 "2013-01-09T21:56:06Z")

</div>

I think u r right! I didnt disable the follow redirect option. I didnt know that its possible to write check even for post requests! so now it looks like :

> .exec(http(“request\_2”)  
> .post(“/DCWAT/”)  
> .headers(headers\_2)  
> .queryParam(“”“-1.IFormSubmitListener-loginForm”“”, “”“”“”)  
> .param(“”“loginForm2db\_hf\_0"”“, “””“”“)  
> .param(”““formDomain””“, “”“xxxx””“)  
> .param(”““formName””“, “”“yyyy””“)  
> .param(”““formPassword””“, “”“zzz””“)  
> .check(regex(”“”
> 
> ## Assignments
> “”"))  
> )

So now I am able to check if “Assignments” exist in the landed page.

Thanks 🙂
