# dynamic header names

**URL:** <https://community.gatling.io/t/dynamic-header-names/5080>\
**Category:** Gatling (Open-Source)\
**Created:** [June 18, 2019, 7:16pm UTC](https://community.gatling.io/t/dynamic-header-names/5080 "2019-06-18T19:16:06Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![David\_Ward](https://avatars.discourse-cdn.com/v4/letter/d/51bf81/32.png) [@David\_Ward](https://community.gatling.io/u/David_Ward)\
**Post date:** [June 18, 2019, 7:16pm UTC](https://community.gatling.io/t/dynamic-header-names/5080/1 "2019-06-18T19:16:06Z")

</div>

Trying to figure out how to set a dynamic header name and header value. I’ve tried using session variables without luck.

Tried this:

---

<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:** [June 18, 2019, 7:25pm UTC](https://community.gatling.io/t/dynamic-header-names/5080/2 "2019-06-18T19:25:42Z")

</div>

You can’t. Header names are static.

---

<div class="post-metadata">

**Author:** ![David\_Ward](https://avatars.discourse-cdn.com/v4/letter/d/51bf81/32.png) [@David\_Ward](https://community.gatling.io/u/David_Ward)\
**Post date:** [June 18, 2019, 7:35pm UTC](https://community.gatling.io/t/dynamic-header-names/5080/3 "2019-06-18T19:35:13Z")

</div>

I have environments that use different sso header names (ex: sso-dev, sso-test). I would like to create a test that can set the correct header name basic on config passed in. I’m tried to use a csv data feeder which included the header name.

Any suggestions on how this could be accomplished?

---

<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:** [June 18, 2019, 7:37pm UTC](https://community.gatling.io/t/dynamic-header-names/5080/4 "2019-06-18T19:37:51Z")

</div>

A system property, a config value, whatever.  
This value is static for a given run and not user dependant, why would you want to use a feeder for this?

---

<div class="post-metadata">

**Author:** ![David\_Ward](https://avatars.discourse-cdn.com/v4/letter/d/51bf81/32.png) [@David\_Ward](https://community.gatling.io/u/David_Ward)\
**Post date:** [June 18, 2019, 7:54pm UTC](https://community.gatling.io/t/dynamic-header-names/5080/5 "2019-06-18T19:54:34Z")

</div>

I’m new to Gatling and scala. I have some basic tests running that use feeders, so I was trying to leverage what I’ve done.

I’ve been able to leaverage a global variable as a header name:

var ssoHdrName = “xxx”

.header(ssoHdrName,"${env\_ssoHdrValue}")

Is there a way to change the value of the variable in a .exec statement, for example:

.exec(session =\> {  
ssoHdrName = session(“env\_ssoHdrName”).as[String]  
println(ssoHdrName)  
session  
})

This runs but the ssoHdrName global variable isn’t updated.

---

<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:** [June 18, 2019, 8:04pm UTC](https://community.gatling.io/t/dynamic-header-names/5080/6 "2019-06-18T20:04:24Z")

</div>

You can’t have user scoped header names, period.

// find a way to set this System property when launching Gatling, depending on how you launch it  
// -DssoHdrName=THE\_VALUE\_YOU\_WANT  
val ssoHdrName = System.getProperty(“ssoHdrName”)

.header(ssoHdrName,"${env\_ssoHdrValue}")
