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

fix(h5): unify the default content-type #7796

Merged
merged 4 commits into from
Oct 9, 2020
Merged

Conversation

yuezk
Copy link
Contributor

@yuezk yuezk commented Oct 8, 2020

这个 PR 做了什么? (简要描述所做更改)

Taro.requestcontent-type 的默认值设置为 application/json,使其和官方文档中的描述一致,方便开发者使用。
这个 issue 最初报在 #1280, 现在可以使用 https://github.com/yuezk/taro_bug/tree/master/h5_request__contentType 复现
image

翻了一下代码的历史记录,发现 #1280103f730 这个 commit 修复,但随后又被 revert 了。看了一下修复的方法,发现原来的方案中添加默认的 content-type 的位置不对,这会导致给所有的没有设置 content-type 的请求设置一个 application/jsoncontent-type,进而会使一些请求出问题。

比较的合适的时机应该当传入的 data 是 object,并且没有指定 content-type 的时候,给 content-type 一个默认值 application/json

这个 PR 是什么类型? (至少选择一个)

这个 PR 满足以下需求:

  • 提交到 master 分支
  • Commit 信息遵循 Angular Style Commit Message Conventions
  • 所有测试用例已经通过
  • 代码遵循相关包中的 .eslintrc, .tslintrc, .stylelintrc 所规定的规范
  • 在本地测试可用,不会影响到其它功能

这个 PR 涉及以下平台:

  • 微信小程序
  • 支付宝小程序
  • 百度小程序
  • 头条小程序
  • QQ 轻应用
  • 快应用平台(QuickApp)
  • Web 平台(H5)
  • 移动端(React-Native)

其它需要 Reviewer 或社区知晓的内容:

@yuezk yuezk marked this pull request as draft October 8, 2020 23:57
@yuezk yuezk marked this pull request as ready for review October 9, 2020 04:44
@luckyadam luckyadam merged commit 89e0ef0 into NervJS:next Oct 9, 2020
@yuezk yuezk deleted the patch-1 branch October 9, 2020 12:28
@Chen-jj
Copy link
Contributor

Chen-jj commented Nov 5, 2020

这个 PR 赋值后没有删除原有 Content-Type 字段,导致 Content-Type 重复设置而请求失败。

@Chen-jj
Copy link
Contributor

Chen-jj commented Nov 5, 2020

#7972

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.

3 participants