Specifying file mime type for multipart requests using python requests module
- 主要語言
- TypeScript
- 星號
- 1.2k
- 分支
- 242
- PR 合併指標
- 30 天內沒有已合併 PR
描述
I'm unable to specify the mime type of the files sent as part of `multipart/form-data` requests using the python requests module.
I believe the relevant code is here: https://github.com/Kong/httpsnippet/blob/master/src/targets/python/requests/client.ts#L82
I was thinking we could support it by making a change like so:
```javascript
if (p.fileName) {
if (p.mimeType) {
files[p.name] = `('${p.fileName}', open('${p.fileName}', 'rb'), '${p.mimeType}')`;
} else {
// current behaviour
files[p.name] = `open('${p.fileName}', 'rb')`;
}
hasFiles = true;
} else {
payload[p.name] = p.value;
hasPayload = true;
}
```
貢獻指南
研究方向
Start in src/targets/python/requests/client.ts around line 82 and inspect how multipart files are assembled for Python requests snippets. Compare the current file handling with the proposed MIME-type behavior, then check nearby tests or target fixtures if present. Done means a file parameter with a MIME type produces the requested multipart tuple while existing file and payload handling remains unchanged.
由索引模型根據 Issue 內容生成。
評估
- 技術堆疊
- python, typescript
- 領域
- api, tooling
- Issue 類型
- 功能
- 難度
- 2/5
- 預估耗時
- 1-3 小時
- 活躍度
- 停滯
- 描述清晰度
- 描述清楚
- 新手友好度
- 45/100