package gatling
import io.gatling.core.Predef._
import io.gatling.http.Predef._
object SessionQuestion {
val scn = {
scenario("SetHeaders")
.exec(session => {
// In Real Life, this list of headers comes from a security library:
val headerMap = Map[String, String]("header1" -> "headerValue1", "header2" -> "headerValue2")
session.set("headers", headerMap)
})
.exec({
// Question is here: How do I read the current session to create the action?
val headerMap: Map[String, String] = null // session.get("headers").asInstanceOf[Map[String, String]]
http("SessionQuestionRequest")
.post("/comments")
.headers(headerMap)
.body(StringBody("some_body"))
.asJSON
.check(
status is 204
)
})
}
}
}
class SessionQuestion extends Simulation {
val httpProtocol = http
.baseURL("http://computer-database.gatling.io")
.acceptHeader("text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8")
.acceptEncodingHeader("gzip, deflate")
.acceptLanguageHeader("en-US,en;q=0.5")
.userAgentHeader("Mozilla/5.0 (Macintosh; Intel Mac OS X 10.11; rv:45.0) Gecko/20100101 Firefox/45.0")
// .disableFollowRedirect
setUp(SessionQuestion.scn.inject(atOnceUsers(10))).protocols(httpProtocol)
}
--
You received this message because you are subscribed to the Google Groups "Gatling User Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to gatling+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.