admin管理员组文章数量:1203976
row body is printed in Postman as TradeSha=https%3A%2F%2Fenv.example%2Fpayments%2FRedirectHandler%2F1002%3FtId%3D100201195%26token%3D9c8dce5b-ddbb-4190-9cbe-3da45fad50d2
Location header is printed as ;token=unknown-token
For this request: POST /mpggateway HTTP/1.1 Host: core-mocks-qa.bglobale Content-Type: application/x-www-form-urlencoded Content-Length: 154
TradeSha=https%3A%2F%2Fenv.example%2Fpayments%2FRedirectHandler%2F1002%3FtId%3D100201195%26token%3D9c8dce5b-ddbb-4190-9cbe-3da45fad50d2
And this mapping in WireMock:
{
"request": {
"urlPattern": "/mpggateway",
"method": "POST",
"headers": {
"Content-Type": {
"matches": "application/x-www-form-urlencoded.*"
}
}
},
"response": {
"status": 302,
"headers": {
"Location": "={{regexExtract request.body 'tId%3D([a-f0-9\\-]+)' 1 default='unknown-token'}}&token={{regexExtract request.body 'token%3D([a-f0-9\\-]+)' 1 default='unknown-token'}}"
},
"body": "Raw Body: {{request.body}}",
"delayDistribution": {
"type": "uniform",
"lower": 500,
"upper": 750
}
},
"metadata": {
"description": "cool"
}
}
I've tried using different regex and also formData helper.
row body is printed in Postman as TradeSha=https%3A%2F%2Fenv.example.com%2Fpayments%2FRedirectHandler%2F1002%3FtId%3D100201195%26token%3D9c8dce5b-ddbb-4190-9cbe-3da45fad50d2
Location header is printed as https://env.example.com/payments/PSPRedirectHandler/1002?tId=unknown-token&token=unknown-token
For this request: POST /mpggateway HTTP/1.1 Host: core-mocks-qa.bglobale.com Content-Type: application/x-www-form-urlencoded Content-Length: 154
TradeSha=https%3A%2F%2Fenv.example.com%2Fpayments%2FRedirectHandler%2F1002%3FtId%3D100201195%26token%3D9c8dce5b-ddbb-4190-9cbe-3da45fad50d2
And this mapping in WireMock:
{
"request": {
"urlPattern": "/mpggateway",
"method": "POST",
"headers": {
"Content-Type": {
"matches": "application/x-www-form-urlencoded.*"
}
}
},
"response": {
"status": 302,
"headers": {
"Location": "https://env.example.com/payments/RedirectHandler/1002?tId={{regexExtract request.body 'tId%3D([a-f0-9\\-]+)' 1 default='unknown-token'}}&token={{regexExtract request.body 'token%3D([a-f0-9\\-]+)' 1 default='unknown-token'}}"
},
"body": "Raw Body: {{request.body}}",
"delayDistribution": {
"type": "uniform",
"lower": 500,
"upper": 750
}
},
"metadata": {
"description": "cool"
}
}
I've tried using different regex and also formData helper.
Share Improve this question edited Jan 21 at 5:55 DarkBee 15.6k8 gold badges70 silver badges114 bronze badges asked Jan 21 at 5:31 lionheartlionheart 43712 silver badges34 bronze badges1 Answer
Reset to default 0The "1" in the handlebars should refer to a variable that should be used afterwards. For example -
{{regexExtract request.body 'token%3D([a-f0-9\\-]+)' 1 default='unknown-token'}}
should be {{regexExtract request.body 'token%3D([a-f0-9\\-]+)' 'parts' default='unknown-token'}}{{parts.1}}
Now it works
本文标签: regexRedirect url from xwwwformurlencoded request doesn39t work out of the boxStack Overflow
版权声明:本文标题:regex - Redirect url from x-www-form-urlencoded request doesn't work out of the box - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1738653028a2104984.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论