2017-09-13 25 views
1

私はスカラーのギャトリングバージョン2.3.0を使用しています。リクエストを送信した後、リダイレクトから変数にURLを取得することは可能ですか?例えば私は192.168.1.30:8080/を要求し、このリンクは192.168.1.30:8080/token/123にリダイレクトされます。/ token/123を取得できますか?私は追加する必要があります) 1:私は、私はこれは私の質問に答えているリダイレクトと間違っているものを知って、このコードを試みたが、エラーheader.find.existsが発生し、何も見つからなかったが、フィドラーで、私は、このヘッダースカラでギャッリングリダイレクトからURLを取得する方法

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 
}) 
+0

これは、あなたの質問に答えるが、([ガトリングが自動的にリダイレクト次の]場合はかなりわからないhttp://gatling.io/docs/current/http/http_protocol /#follow-redirects) – Phonolog

答えて

0

を見ますシナリオにHTTPCONF .disableFollowRedirectと.check(status.is(302))へ

val httpConf = http 
    .baseURL("192.168.1.30:8080") // Here is the root for all relative URLs 
    .acceptHeader("text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8") // Here are the common headers 
    .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") 
    .disableFollowRedirect 

val scn = scenario("SCENARIO2") 
    .exec(http("open") 
     .get("/") 
     .check(status.is(302)) 
     .check(header("Location").saveAs("url"))) 
    .exec(session => { 
     val urlN = session.get("url").asOption[String] 
     print(urlN.getOrElse("nothing")) 
     session 
    }) 
関連する問題