Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

nvue下request请求的几个问题记录:持续更新 #1098

Closed
wakaryry opened this issue Dec 9, 2019 · 1 comment
Closed

nvue下request请求的几个问题记录:持续更新 #1098

wakaryry opened this issue Dec 9, 2019 · 1 comment
Assignees
Labels
duplicate This issue or pull request already exists

Comments

@wakaryry
Copy link

wakaryry commented Dec 9, 2019

  • 2.4.4 alpha;
  • ios/wechat mp/h5;
  • nvue;
  • Java/Python backend(all tested)

POST with application/x-www-form-urlencoded

in we chat mp

what we got in backend:

b'phone=17610779055&type=register&product=1'
<QueryDict: {'phone': ['17610779055'], 'type': ['register'], 'product': ['1']}>
application/x-www-form-urlencoded

It's normal.

in IOS App

what we got in backend:

b'{\n  "phone" : "17610779055",\n  "type" : "register",\n  "product" : 4\n}'
<QueryDict: {'{\n  "phone" : "17610779055",\n  "type" : "register",\n  "product" : 4\n}': ['']}>
application/x-www-form-urlencoded

It's not what we want.

同时在Java和Python后台有过测试。

可以看出iOS app 上面 data 打包有问题。

以上问题触发,似乎存在一定的触发条件。

当新建一个项目,然后完全按照自己的写法来做请求的时候,会发现后台得到的内容又是正常的,但是将测试正常的代码,放在特定的项目里面,它又不正常。

可能会说是项目的问题,但是事实上,在mp和h5是正常的,而且所有的内容都没有报错。

并且,我们完全不做任何封装,也不调用任何模块,直接使用uni.request来请求,放在特定的项目里面,后台接收到的数据也不正常。当然,这个拿出来新建一个项目,同样的请求,后台接收数据又正常。

现在还没有弄明白是哪个地方,或者是什么样的写法会导致这个问题的出现。data的打包不是我这边控制的,是uni根据请求的content-type来打包的。按理说这应该是独立的东西,不会受到我项目的影响,更加不会存在新建一个项目可以使用,换一个项目就不能正常工作的情况。很诡异。

我也在一步步把项目拆开,然后拼凑起来,每一次看一下,是不是有问题,然后找出来多了什么内容,会导致data打包变得异常。

POST with upload file

in we chat mp

<QueryDict: {'product': ['1'], 'avatar': [<InMemoryUploadedFile: wx6ac33db0a03b62b0.o6zAJs0oqWWXZCO4cxPFnuebq9kE.yPD2kkr9RPdq77bc6f33eb8d9597eac50a8b87e5ac80.jpeg (image/jpeg)>]}>
multipart/form-data; boundary=--------------------------835982688761892860460268

in ios app

<QueryDict: {'avatar': [<InMemoryUploadedFile: 1575860040556.jpg (image/jpeg)>]}>
multipart/form-data; boundary=io.dcloud.uploader15758600419539

But the product param is gone.

iOS app 上面 丢失了 formData中的参数。

@dcloudhdx
Copy link
Contributor

HBuilderX 2.4.7 alpha 版本已修复

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
duplicate This issue or pull request already exists
Projects
None yet
Development

No branches or pull requests

4 participants