首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >无法在空手道框架中解码表单字段数据

无法在空手道框架中解码表单字段数据
EN

Stack Overflow用户
提问于 2021-10-06 11:51:01
回答 1查看 48关注 0票数 1

我最近学到了空手道,这是一个很棒的工作经历。我被困在一个问题上,并从不同的网站上寻找解决方案,但它没有帮助

场景:当方法POST然后状态302时,给定url "https://test.payu.in/_payment“和表单域surl = '/payu/web-response/17703721?appVersion=null&clientId=web-client/1.0‘

当我们点击上面的请求时,表单字段值被编码为'surl=%2Fpayu%2Fweb-response%2F17703721%3FappVersion%3Dnull%26clientId%3Dweb-client%2F1.0‘,因为这个请求失败了

如果你能给我提供解决方案,那将是非常有帮助的解决方案尝试: java.net.URLDecoder.decode('/payu/web-response/17703721?appVersion=null&clientId=web-client/1.0','UTF-8')

但没那么走运

EN

回答 1

Stack Overflow用户

发布于 2021-10-06 12:09:34

空手道是在做正确的事情。你可以使用这个3行的空手道测试来亲眼看看:

代码语言:javascript
复制
* url 'https://httpbin.org/anything'
* form field foo = 'one/two?three=four'
* method post

您可以看到“原始”请求是:

代码语言:javascript
复制
1 > POST https://httpbin.org/anything
1 > Content-Type: application/x-www-form-urlencoded
1 > Content-Length: 28
1 > Host: httpbin.org
1 > Connection: Keep-Alive
1 > User-Agent: Apache-HttpClient/4.5.13 (Java/11.0.11)
1 > Accept-Encoding: gzip,deflate
foo=one%2Ftwo%3Fthree%3Dfour

但是在响应中,您可以看到服务器正确地处理了它:

代码语言:javascript
复制
1 < 200
1 < Date: Wed, 06 Oct 2021 12:06:10 GMT
1 < Content-Type: application/json
1 < Content-Length: 513
1 < Connection: keep-alive
1 < Server: gunicorn/19.9.0
1 < Access-Control-Allow-Origin: *
1 < Access-Control-Allow-Credentials: true
{
  "args": {}, 
  "data": "", 
  "files": {}, 
  "form": {
    "foo": "one/two?three=four"
  }, 
  "headers": {
    "Accept-Encoding": "gzip,deflate", 
    "Content-Length": "28", 
    "Content-Type": "application/x-www-form-urlencoded", 
    "Host": "httpbin.org", 
    "User-Agent": "Apache-HttpClient/4.5.13 (Java/11.0.11)", 
    "X-Amzn-Trace-Id": "Root=1-615d9132-260dcbf96f57a6992b6273dc"
  }, 
  "json": null, 
  "method": "POST", 
  "origin": "122.179.54.225", 
  "url": "https://httpbin.org/anything"
}

请参阅响应中名为form的JSON字段。

我认为你应该做一些研究,或者和你的“服务器”团队谈谈。谁知道呢,也许空手道给你找了个bug。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/69465187

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档