# How to partially set disableFollowRedirect=false with globally set it to true?

**URL:** <https://community.gatling.io/t/how-to-partially-set-disablefollowredirect-false-with-globally-set-it-to-true/3149>\
**Category:** Gatling (Open-Source)\
**Created:** [July 20, 2016, 3:30am UTC](https://community.gatling.io/t/how-to-partially-set-disablefollowredirect-false-with-globally-set-it-to-true/3149 "2016-07-20T03:30:49Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![sunbeltdn](https://avatars.discourse-cdn.com/v4/letter/s/e5b9ba/32.png) [@sunbeltdn](https://community.gatling.io/u/sunbeltdn)\
**Post date:** [July 20, 2016, 3:30am UTC](https://community.gatling.io/t/how-to-partially-set-disablefollowredirect-false-with-globally-set-it-to-true/3149/1 "2016-07-20T03:30:49Z")

</div>

Hi All,  
We try to use gatling for our testing driver to replace the old one, but I encounter one problem:

The requirement from my testing of login logic, which is some complex  
The login has two part of redirect, for 1st redirect, I need to disableFollowRedirect as I need to find token in the redirected page:

group(“LoadLoginPage”) {  
exec(  
http(“req1”)  
.get(host + “/” + contextRoot)  
.check(status.is(302))  
.check(header(“Location”).saveAs(“nextRedirectURL”))  
)

.exec(  
http(“req2”)  
.get("${nextRedirectURL}")  
.check(status.is(200))  
.check(regex(“token = ‘(.+?)’;”).saveAs(“token”))  
)  
}

Then in next chains of redirect, I need to set disableFollowRedirect as false, as I need the server to do the redirect to another host for 3rd party authorization instead of gatling as client, the chain disableFollowRedirect = true as below

exec(  
http(“reg3”)  
.post("${nextRedirectURL}")  
.formParam(“login”, “${username}”)  
.formParam(“password”, “${password}”)  
.formParam(“token”, “${token}”)  
.check(header(“Location”).saveAs(“nextRedirectURL”))

)

.exec(http(“req4”)  
.get("${nextRedirectURL}")  
.check(header(“Location”).saveAs(“nextRedirectURL”))

)

.exec(  
http(“reg5”)  
.get(“nextRedirectURL”)  
.check(status.is(200))  
)

)

I checked the documents, seems no way to resovle it? So ask here whether I can implement this in some way? Thanks!

---

<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:** [July 20, 2016, 6:03am UTC](https://community.gatling.io/t/how-to-partially-set-disablefollowredirect-false-with-globally-set-it-to-true/3149/2 "2016-07-20T06:03:15Z")

</div>

Could you please explain why you can’t let Gatling perform redirects automatically and let it deal with cookies transparently, just like a normal browser would?

---

<div class="post-metadata">

**Author:** ![sunbeltdn](https://avatars.discourse-cdn.com/v4/letter/s/e5b9ba/32.png) [@sunbeltdn](https://community.gatling.io/u/sunbeltdn)\
**Post date:** [July 21, 2016, 12:22am UTC](https://community.gatling.io/t/how-to-partially-set-disablefollowredirect-false-with-globally-set-it-to-true/3149/3 "2016-07-21T00:22:49Z")

</div>

Hi Stéphane,

Thanks for response!

The reason is in the first group: “LoadLoginPage”, need to save a token which will be used in req3 and that is a redirected page, so I need to disable auto redirect, and then in req4 need the server to do the redirect to another host for 3rd party authorization instead of gatling as client.

在 2016年7月19日星期二 UTC-7下午11:03:47，Stéphane Landelle写道：

---

<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:** [July 21, 2016, 5:44am UTC](https://community.gatling.io/t/how-to-partially-set-disablefollowredirect-false-with-globally-set-it-to-true/3149/4 "2016-07-21T05:44:51Z")

</div>

From [doc](http://gatling.io/docs/2.2.2/http/http_check.html?highlight=landing):

By default, Gatling follows redirects (can be disabled in the protocol). If this behavior is enabled, checks will ignore intermediate responses and **will target the landing response**.

---

<div class="post-metadata">

**Author:** ![sunbeltdn](https://avatars.discourse-cdn.com/v4/letter/s/e5b9ba/32.png) [@sunbeltdn](https://community.gatling.io/u/sunbeltdn)\
**Post date:** [July 22, 2016, 12:07am UTC](https://community.gatling.io/t/how-to-partially-set-disablefollowredirect-false-with-globally-set-it-to-true/3149/5 "2016-07-22T00:07:39Z")

</div>

Hi Stéphane,  
yes, I read the doc, so it means that it can not switch during the testing?

Whether this will be a feature in next version?

Thanks!

在 2016年7月20日星期三 UTC-7下午10:45:23，Stéphane Landelle写道：

---

<div class="post-metadata">

**Author:** ![sunbeltdn](https://avatars.discourse-cdn.com/v4/letter/s/e5b9ba/32.png) [@sunbeltdn](https://community.gatling.io/u/sunbeltdn)\
**Post date:** [August 24, 2016, 2:54am UTC](https://community.gatling.io/t/how-to-partially-set-disablefollowredirect-false-with-globally-set-it-to-true/3149/6 "2016-08-24T02:54:35Z")

</div>

Hi _Stéphane ,_

_Forget to update~~~_

_the problem has been resolved, it is not related for auto redirect, but other problem._

_Nice performance testing tool:)_

在 2016年7月20日星期三 UTC-7下午10:45:23，Stéphane Landelle写道：
