How to pass session map variable to headers

basically the variable “C_Login” will have the map values of headers and trying on how to session MAP variable to headers.

 .exec(_.setAll(Map("C_login" -> Login.loginSessionVariables.get("login_matchProxyPerson").get)))
//      .exec { session =>
//        val newSession = session.setall("foo", "bar")
//        newSession
//      }
        .feed(accountIdPayloadfeeder)
          .pace(gatlingVariableConfig.pace_time)
          .exec(
            http("T01_ReactMatchProxyPerson")
              .post("/v1/match/person")
              .headers( session => session("C_login").as[String])

@slandelle could you please suggest on how it could be implemented differently.

here is the details, that you are looking

the following lines of codes are in the Login.scala file

var temp=MapCharSequence,String
temp+= “x-ziaccesstoken” → session(“C_ziaccesstoken”).as[String]
temp+= “x-ziid” → jwt.getclaims.get(“ziid”)
temp+= “x-zisession” → jwt.getclaims.get(“zisession”)
loginSessionVariables+= name → temp

Thanks for the prompt reply, tried the same solution some time abck

headers method accepts only string parameter only , this is problem here

val loginSessionVariables = scala.collection.mutable.MapString, Map[CharSequence,String]

Oh right, indeed, we don’t support this, my bad.

Just wondering why you can’t use this. Seems to me that the Object Login.loginSessionVariables is an immutable Map[String, Map[String, String]]

  http("T01_ReactMatchProxyPerson")
    .post("/v1/match/person")
    .headers(Map("C_login" -> Login.loginSessionVariables.get("login_matchProxyPerson").get))

No, the core thing is that we currently require to know all the header names statically, before resolving the dynamic parts, including the header values.
So it’s neither possible to have dynamic header names, nor have a dynamic list of headers.

That being said, in the present case, I’m pretty sure that Login.loginSessionVariables.get("login_matchProxyPerson").get returns a fixed set of headers, and possibly a single one (Authorization). If that’s the case, it could be implemented differently.

your input is required here
@slandelle could you please suggest on how it could be implemented differently.

here is the details, that you are looking

the following lines of codes are in the Login.scala file

var temp=Map[CharSequence,String]
temp+= “x-ziaccesstoken” → session(“C_ziaccesstoken”).as[String]
temp+= “x-ziid” → jwt.getclaims.get(“ziid”)
temp+= “x-zisession” → jwt.getclaims.get(“zisession”)
loginSessionVariables+= name → temp

[/quote]

Something like:

.header("x-ziaccesstoken", "#{C_login.x-ziaccesstoken}")
.header("x-ziid", "#{C_login.x-ziid}")
.header("x-zisession", "#{C_login.x-zisession}")

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.