[英]Gatling Transforming Variables
Following some good feedback on previous issue: 在对之前的问题提出了一些好的反馈意见之后:
Gatling-tool Extracting cookie data 加特林工具提取Cookie数据
I have a post request in my gatling simulation which looks like the following: 我在gatling模拟中有一个发帖请求,该请求如下所示:
.post("/checkout/onepage/form_key/${formkey}")
The variable ${formkey} is populated from a cookie value using: 使用以下命令从cookie值填充变量$ {formkey}:
.check(headerRegex("Set-Cookie","CACHED_FRONT_FORM_KEY=(.*)").saveAs("formkey"))
This appears to work correctly, however I now have an issue with: 这似乎可以正常工作,但是我现在遇到了一个问题:
java.net.URISyntaxException: Illegal character in path at index 90
Obviously I need to escape the special characters in the variable, but I'm unsure of how best to do this. 显然,我需要对变量中的特殊字符进行转义,但是我不确定如何最好地做到这一点。
Gatling does provide a transform function: 加特林确实提供了转换功能:
https://github.com/excilys/gatling/wiki/Checks#wiki-transforming https://github.com/excilys/gatling/wiki/Checks#wiki-transforming
I'm hoping I can use this to escape the characters. 我希望我可以用它来逃脱角色。 Any ideas would be greatly appreciated. 任何想法将不胜感激。
Yes, query paremeter parts must be URLEncoded. 是的,查询参数部分必须使用URLEncoded。
In Gatling 1, transform takes a String and returns a String, so you would have something like: 在Gatling 1中,transform需要一个String并返回一个String,所以您将得到以下内容:
.transform(rawCookieValue => java.net.URLEncoder.encode(rawCookieValue, "UTF-8"))
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.