-
Notifications
You must be signed in to change notification settings - Fork 328
Labels
in: fitIssues in FIT modulesIssues in FIT modulestype: enhancementA general enhancementA general enhancement
Milestone
Description
功能摘要 / Feature Summary
HTTP客户端支持发送multipart/*格式的请求,包括multipart/form-data、multipart/mixed等
功能类型 / Feature Type
API改进 / API Enhancement
优先级 / Priority
中 - 有了更好 / Medium - Would be nice to have
问题描述 / Problem Description
当前fit-framework的HTTP客户端不支持发送multipart/*格式的请求,这限制了以下使用场景:
- 文件上传功能 - 无法通过HTTP客户端上传文件到远程服务器
- 表单数据提交 - 无法发送包含文件和其他字段的复合表单数据
- 多媒体内容传输 - 无法发送包含多种数据类型的混合内容
- 与第三方API集成 - 许多第三方服务API要求使用multipart/form-data格式
这个限制使得开发者在需要文件上传或复杂表单提交时,必须寻找其他解决方案或使用额外的HTTP客户端库。
建议的解决方案 / Proposed Solution
在fit-framework的HTTP客户端中添加对multipart/*格式的原生支持:
-
支持multipart/form-data格式:
- 提供简单的API来构建包含文件和文本字段的表单数据
- 自动设置正确的Content-Type头部和boundary参数
- 支持多文件上传
-
支持multipart/mixed格式:
- 允许在一个请求中发送多种类型的数据
- 支持自定义每个部分的Content-Type
-
API设计建议:
- 当前
HttpClassicClientRequest的API不需要修改,已经支持了multipart/*的发送,后续的序列化部分不支持 - 通过设置
HttpClassicClientRequest.entity(PartitionedEntity entity)方法进行发送
- 当前
-
自动处理:
- 自动生成boundary分隔符
- 正确编码multipart数据
- 设置合适的Content-Length头部
替代方案 / Alternative Solutions
目前的替代方案包括:
- 使用其他HTTP客户端库 - 如Apache HttpClient、OkHttp等,但这会增加依赖复杂性
- 手动构建multipart数据 - 开发者需要自己处理boundary、编码等细节,容易出错且代码复杂
- 通过代理服务 - 创建一个中间服务来处理multipart请求,增加了系统复杂性
确认事项 / Confirmations
-
我已经搜索了现有的 issues 和讨论,确认这不是重复建议
I have searched existing issues and discussions, confirming this is not a duplicate suggestion -
这个功能符合项目的目标和范围
This feature aligns with the project's goals and scope -
我理解这个功能可能需要时间来实现
I understand this feature may take time to implement -
我愿意协助实现这个功能 (可选)
I'm willing to help implement this feature (optional)
Metadata
Metadata
Assignees
Labels
in: fitIssues in FIT modulesIssues in FIT modulestype: enhancementA general enhancementA general enhancement