karate - 空手道 api 测试正在将 @ 转换为 %40,同时拨打电话
问题描述
我已经使用空手道框架编写了一个 api 测试。在进行邮寄呼叫时,它将电子邮件字段的值从 TEST@ABC.COM 转换为 TEST%40ABC.COM。
这是日志中的几行
1 > Content-Type: application/x-www-form-urlencoded; charset=UTF-8
1 > User-Agent: Apache-HttpClient/4.5.5 (Java/1.8.0_221)
email=TEST%40ABC.COM&checkDigit=&brandName=
解决方案
根据 HTTP 规范,这是正确的:https ://stackoverflow.com/a/53638335/143475
你可以自己看看,试试这个:
* url 'http://httpbin.org'
* path 'anything'
* form field username = 'john@smith.com'
* form field password = 'secret'
* method post
结果:
1 > Accept-Encoding: gzip,deflate
1 > Connection: Keep-Alive
1 > Content-Length: 41
1 > Content-Type: application/x-www-form-urlencoded; charset=UTF-8
1 > Host: httpbin.org
1 > User-Agent: Apache-HttpClient/4.5.12 (Java/1.8.0_231)
username=john%40smith.com&password=secret
但是当您看到响应时,您可以看到服务器正确处理了它,查看form
JSON 中的:
1 < 200
1 < Access-Control-Allow-Credentials: true
1 < Access-Control-Allow-Origin: *
1 < Connection: keep-alive
1 < Content-Length: 555
1 < Content-Type: application/json
1 < Date: Tue, 07 Apr 2020 13:11:58 GMT
1 < Server: gunicorn/19.9.0
{
"args": {},
"data": "",
"files": {},
"form": {
"password": "secret",
"username": "john@smith.com"
},
"headers": {
"Accept-Encoding": "gzip,deflate",
"Content-Length": "41",
"Content-Type": "application/x-www-form-urlencoded; charset=UTF-8",
"Host": "httpbin.org",
"User-Agent": "Apache-HttpClient/4.5.12 (Java/1.8.0_231)",
"X-Amzn-Trace-Id": "Root=1-5e8c7c1e-affe121cae9f4b20399b0884"
},
"json": null,
"method": "POST",
"origin": "49.206.10.30",
"url": "http://httpbin.org/anything"
}
推荐阅读
- java - 即使 Junit 是绿色的,Wiremock 也显示零代码覆盖率
- powershell - 在Powershell中重新排列IF语句时的输出切换
- mongodb - 从 MongoDB 集合创建密钥列表 - Mongoosh / MongoDB 脚本
- odoo-14 - 在odoo14中删除自动完成
- .htaccess - .htaccess 的尾部斜杠问题
- go - 如何使用 go-git 包获取特定哈希的 git 标签以获取类似于 git describe --tags --always 的输出
- javascript - Formik React 电子邮件域验证
- regex - sed:匹配ANSI颜色的特殊字符
- python-3.x - 训练cnn时出现ResourceExhaustedError
- spring-webflux - 限制通过 spring webflux 发送的数据