How to get url from redirect?

58 views
Skip to first unread message

anik proxi

unread,
Sep 13, 2017, 6:03:50 AM9/13/17
to Gatling User Group
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?

 val scn = scenario("Scenario Name") 
    .exec(http("Open")
      .get("/"))

anik proxi

unread,
Sep 14, 2017, 9:02:55 AM9/14/17
to Gatling User Group
I tried with this but occurs error header<Location>.find.exists, found nothing but in Fiddler I see this header

val scn = scenario("SCENARIO2")
    .exec(http("open")
      .get("/")
      .check(header("Location").saveAs("url")))
    .exec(session => {
      val urlN = session.get("url").asOption[String]
      print("TEST123 " + urlN.getOrElse("nie ma"))
      session
    })

Nige

unread,
Sep 14, 2017, 6:39:24 PM9/14/17
to Gatling User Group
By default, redirects occur automatically, and any checks are performed only at the last redirection ('landing') location, which will not have a 'Location' header in the response.

It seems you need to (globally) override this behaviour with disableFollowRedirect applied to your HTTP configuration ( ref. http://gatling.io/docs/current/cheat-sheet/ ,  HTTP Protocol / Options ), and handle redirections yourself.  A temporary/local override would be nice, but there isn't one.

Also see https://groups.google.com/forum/#!topic/gatling/CfP8hSfcFXs .
Reply all
Reply to author
Forward
0 new messages