Skip to content

advise: use rawBody as the urllib data#11

Open
luckyscript wants to merge 1 commit intoeggjs:masterfrom
luckyscript:patch-1
Open

advise: use rawBody as the urllib data#11
luckyscript wants to merge 1 commit intoeggjs:masterfrom
luckyscript:patch-1

Conversation

@luckyscript
Copy link

@luckyscript luckyscript commented Jul 31, 2023

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呢

use rawBody as the urllib data
@luckyscript
Copy link
Author

@atian25 大佬有空可以看下这个PR么,不知道是否合理。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant

Comments