egg-http-proxy
egg-http-proxy copied to clipboard
advise: use rawBody as the urllib data
use rawBody as the urllib data
Checklist
- [ ]
npm test
passes - [ ] tests and/or benchmarks are included
- [ ] documentation is changed or added
- [ ] commit message follows commit guidelines
Affected core subsystem(s)
Description of change
这里转发请求的时候,是否应该使用rawBody呢?使用requestBody可能会导致请求不一样,以下是case: 在content-type为 x-www-form-urlencoded 的情况下,是可以传递数组的,如:
var formdata = new FormData()
FormData.append('arr[]', 1)
FormData.append('arr[]', 2)
这种请求,在egg这里解析后,requestBody为
{ arr: ["1", "2"]}
rawBody为
arr%5B%5D=1&arr%5B%5D=2
如果将requestBody作为urllib的body传输 则发送的formdata实质为:
arr[1]: 1
arr[2]: 2
即 arr%5B1%5D=1&arr%5B2%5D=2
因此想问下这里为啥不直接采用rawBody呢
@atian25 大佬有空可以看下这个PR么,不知道是否合理。