Gatling in scala how to get url from redirect

Viewed 6796

I using gatling ver 2.3.0 in scala. Is it possible after send request get a url from redirect to variable? e.g. I request for 192.168.1.30:8080/ and this link redirect me to 192.168.1.30:8080/token/123, can I get /token/123? I tried with this code but occurs error header.find.exists, found nothing but in Fiddler I see this header

 val httpConf = http
        .baseURL("http://192.168.1.30:8080")
 .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.8; rv:16.0) Gecko/20100101 Firefox/16.0")

val scn = scenario("SCENARIO2")
.exec(http("open")
  .get("/")
  .check(header("Location").saveAs("url")))
.exec(session => {
  val urlN = session.get("url").asOption[String]
  print(urlN.getOrElse("nothing"))
  session
})
1 Answers
Related